How the software interacts:
1. How the console interacts,
2. Interactive mode of graphical interface.
The graphics classes used in Java are mainly in java.awt and javax.swing packages.
The difference between java.awt and javax.swing package:
The graphics classes used in java.awt are all dependent on the system's graphics library.
The graphics classes used by the Javax.swing package are implemented by sun itself and do not require a system-dependent graphics library.
Question: Since the graphics class in the swing package has replaced the AWT package graphics class, why not delete AWT?
1, swing than the AWT package appears late, so there will be some interface is using the AWT package related classes and methods, delete will bring impact.
2, the AWT package contains not only the image class, there are other classes and methods. The two are only very high similarity on the graph class, while others are not.
All of the graphics classes in Java are called component classes.
Categories of components:
----------| Container components
----------| Non-container components
Public classDemo1 { Public Static voidMain (string[] args) {JFrame frame=NewJFrame ("This is my first example of a graphical interface."); //set the size of a form//frame.setsize (300,400); //set the position where the form (upper-left corner) appears//frame.setbounds ((1366-300)/2, (768-400)/2, 300,400);//The first parameter is the x-coordinate of the upper-left corner, and the second parameter is the coordinate of the upper-left corner y. The third form is wide, and the fourth form is high. Initframe (Frame, -, -); Frame.setvisible (true);//setvisible Set the visibility of the form. //set up a form Close eventframe.setdefaultcloseoperation (jframe.exit_on_close); } //Gets the screen's resolution setting form centered on the screen. Public Static voidInitframe (JFrame frame,intwidth,intheight) {Toolkit Toolkit= Toolkit.getdefaulttoolkit ();//gets a system-related tool class object//get the screen resolutionDimension d =toolkit.getscreensize (); intx = (int) d.getwidth (); inty = (int) d.getheight (); Frame.setbounds ((x-width)/2, (Y-height)/2, width, height); } }
Java notes in the graphic class of the detailed