(1) Import swing Package
(2) Select the interface style
(3) Setting the top-level container
(4) Setting buttons and labels
(5) Placing the component on the container
(6) Add a border to the component
(7) Handling events
(8) Auxiliary technical support
1 Packagecom.myswing;2 Importjava.awt.Dimension;3 ImportJava.awt.Toolkit;4 5 Importjavax.swing.*;6 Public classoneswing {7 8 Private Static voidCreateandshowgui () {9 Ten One //Creating and setting Windows AJFrame frame =NewJFrame ("Helloworldswing"); -Frame.setdefaultcloseoperation (Jframe.exit_on_close);//the action of the Close button is the exit window - the //Add Panel -JPanel Panel =NewJPanel (); - Frame.setcontentpane (panel); - + //Add "Hello World" tab -JLabel label =NewJLabel ("Hello World"); + panel.add (label); A at //Set Window Size -Frame.setsize (400, 100); - - //the action of the Close button is the exit window - frame.setdefaultcloseoperation (jframe.exit_on_close); - in //The Settings window is visible and is not visible by default -Frame.setvisible (true); to + //fixed window size -Frame.setresizable (false); the * } $ Panax Notoginseng Public Static voidMain (string[] args) { - Createandshowgui (); the } +}
Steps to create a swing