I. java. AWT. Toolkit ----- used to obtain the screen size, that is, width and height.
Int width = toolkit. getdefatooltoolkit (). getscreensize (). width; get the screen width
Int Height = toolkit. getdefatooltoolkit (). getscreensize (). height; get the screen height
Ii. javax. Swing. joptionpane ------- used to set the pop-up box
Joptionpane. showmessagedialog (parentcomponent, string message); set the pop-up information box.
Int result = joptionpane. showconfirmdialog (parent, string message). The confirmation box is displayed.
Result = 0, it is "yes"
Result = 1, it is "no"
Result = 2, it is "canceled ";
String STR = joptionpane. showinputdialog ("input information:") sets the pop-up input box and returns the input information.
3. java. AWT. event. mouselistener ------- interface of the mouse event
There are many methods, but the most important of them is
(1) Public void mouseclicked (mouseevent e ){}
(2) Public void mousepressed (mouseevent e ){}
(3) Public void mousereleased (mouseevent e ){}
If you implement the mouselistener interface, you must implement all the methods. However, if you inherit the mouseadapter, you only need to implement the necessary methods.
Note: execution sequence of the mouselistener event
Click the mouse and the execution sequence is: mousepressed ---> mousereleased ---> mouseclicked
Common mouseevent methods:
(1) E. getx ();
(2) E. Gety ();
4. java. AWT. Graphics ----- used for plotting
(1) G. drawstring (string STR, int X, int y); draw a string in the figure (x, y.
(2) g. drawoval (int x, int y, int width, int height); draw a hollow ellipse in the figure. X and Y are the upper left corner of the ellipse.
(3) g. filloval (int x, int y, int width, int height); draw a solid ellipse in the figure.
(4) g. drawrect (int x, int y, int width, int height); draw a hollow rectangle in the figure.
(5) g. fillrect (int x, int y, int width, int height );
(6) g. setcolor (color C); set the color of the drawing.
(7) g. setfont (font F); set the font.
(8) g. drawimage (bufferedimage I); draw an image and talk about it later.
V. java. AWT. image. bufferedimage and javax. ImageIO. ImageIO ---- import and draw images
Bufferedimage image = ImageIO. Read (new file ("demo.jpg "));
G. drawimage (image );