Java User Interface window

Source: Internet
Author: User

Java User Interface window

Window box

The code is as follows:

Package Day08; Import Java.awt.Color;
Import Java.awt.FlowLayout;
Import Java.awt.Font;
Import Java.awt.gridlayout;import Javax.swing.JButton;
Import Javax.swing.JFrame;
Import Javax.swing.JLabel;
Import Javax.swing.JPanel;
Import Javax.swing.border.Border;
Import Javax.swing.border.LineBorder;
Import Javax.swing.border.TitledBorder; @SuppressWarnings ("Serial")
public class Testswingcommonfeatures extends JFrame {
Public Testswingcommonfeatures () {
JPanel jp1 = new JPanel (new FlowLayout (Flowlayout.left, 2, 2));
JButton jbtleft = new JButton ("left");
JButton jbtcenter = new JButton ("Center");
JButton jbtright = new JButton ("right");
Jbtleft.setbackground (Color.White);
Jbtcenter.setforeground (Color.green);
Jbtright.setbackground (New Color (10, 100, 100));
Jbtright.settooltiptext ("The right Button");
Jp1.add (Jbtleft);
Jp1.add (Jbtcenter);
Jp1.add (Jbtright);
Jp1.setborder (New Titledborder ("3 buttons")); Border Lineborder = new Lineborder (Color.Black, 2);
Font largefont = new Font ("Blackbody", Font.Bold, 20); JPanel JP2 = new JPanel (new GridLayout (1, 2, 5, 5));
JLabel lbl1 = new JLabel ("Red");
JLabel lbl2 = new JLabel ("Orange");
Lbl1.setfont (Largefont);
Lbl1.setforeground (color.red);
Lbl1.setborder (Lineborder);
Lbl2.setforeground (Color.orange);
Lbl2.setborder (Lineborder);
Jp2.add (LBL1);
Jp2.add (LBL2);
Jp2.setborder (New Titledborder ("2 Labels"));

SetLayout (New GridLayout (2,1,5,5));
Add (JP1);
Add (JP2);
}
public static void Main (string[] args) {
Testswingcommonfeatures frame = new Testswingcommonfeatures ();
Frame.settitle ("Testswingcommonfeatures");
Frame.setsize (+);//set the frame size
Frame.setlocationrelativeto (null);//Center A Frame
Frame.setdefaultcloseoperation (jframe.exit_on_close);//Center A Frame
Frame.setvisible (true);//display the Frame}}

Java User Interface window

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.