My first JApplet-drawing smiling faces, japplet-drawing smiling faces
BeginnerJavaThere are many things that I don't quite understand, but I don't know much about it when I was a beginner in C language. I first read the program in the book, and then I naturally understood it when I used more!
Next, let's briefly introduce the first small Java app I learned by myself-drawing smiling faces. below is the source code and parsing
Source code:
Import java. awt. Graphics;
Import javax. swing. JApplet;
Public class face extends JApplet
{
Public void paint (Graphics canvas)
{
Canvas. drawOval (200,200, 50 );
Canvas. fillOval (155,100, 10, 20 );
Canvas. fillOval (230,100, 10, 20 );
Canvas. drawArc (150,160,100, 50,180,180 );
}
}
Simple parsing: the first two lines of the program are descriptive statements, similar to the file inclusion statement in C language. The "public class face" statement is the class statement we created. The "extends JApplet" statement indicates that we are defining a small application rather than other classes. This is very important. Without these two words, compile
If the main method is not available, then the applet cannot run. The content is the specific method of drawing!
Run:
Conclusion: The journey of a thousand miles begins with a step!