Java Swing Interface Programming (2) --- label component (JLabel)

Source: Internet
Author: User

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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.