Package com. beyole. util; import java. awt. color; import java. awt. dimension; import java. awt. point; import javax. swing. JFrame; import javax. swing. JLabel; public class test2 {public static void main (String [] args) {JFrame frame = new JFrame ("welcome to mldn "); // instantiate the window program JLabel label = new JLabel ("MLDN", JLabel. CENTER); // instantiate the object using CENTER-aligned frame. add (label); // add Dimension dimension = new Dimension () to the container; // instantiate dimensiondimension. setSize (); // you can specify the frame size. setSize (dimension); // sets the component size frame. setBackground (Color. white); // set the background color Point point = new Point (300,200); // set the displayed coordinate frame. setLocation (point); // set the frame position displayed in the form. setVisible (true); // display the component }}
This is the second swing program, which is familiar with the JLabel component. In fact, it is not very abstract, as long as you are careful, you can still.
Program running result: