Learn the Java window Basic Operation boring writing

Source: Internet
Author: User

Learn the Java window Basic Operation boring writing

Just as a record.

The code is as follows:

Package day08;

Import Java.awt.BorderLayout;
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.LineBorder;
Import Javax.swing.border.TitledBorder;

public class Testketianglianxin extends JFrame {
Public Testketianglianxin () {

Font font1 = new Font ("Serif", Font.Bold + Font.Italic, 20);
Font jbutton1 = new Font ("Dialog", Font.plain + Font.Bold, 20);
Font count1 = new Font ("italic", Font.Bold + Font.plain, 20);

Titledborder help = new Titledborder ("Hello World");
Titledborder Titledborder = new Titledborder ("three buttons");

Lineborder LB1 = new Lineborder (color.red,4);
Lineborder lb2 = new Lineborder (color.orange,4);




JPanel p1 = new JPanel (new FlowLayout (Flowlayout.left));
JButton btn1 = new JButton ("left");
Btn1.setforeground (New Color (framebits));
Btn1.settooltiptext ("00000000");
Btn1.setfont (FONT1);

JButton JButton = new JButton ("center");
Jbutton.setforeground (New Color (120, 25, 30));
Jbutton.setfont (Jbutton1);

JButton jbutton2 = new JButton ("right");
Jbutton2.setfont (COUNT1);

P1.add (JButton);
P1.add (BTN1);
P1.add (Jbutton2);
JPanel p2 = new JPanel (new GridLayout);
JLabel Label1 = new JLabel ("Red");
JLabel label2 = new JLabel ("Orange");
P2.add (Label1);
P2.add (Label2);

Label1.setborder (LB1);
Label2.setborder (LB2);

//font help1 = new Font ("italic", Font.Bold + font.plain, +);
Create border
//set border for P1
P1.setborder (titledborder);
P2.setborder (Help);
SetLayout (New GridLayout (2, 1, 5, 5));
Add (p1);
Add (p2);
}

public static void Main (string[] args) {
Testketianglianxin FR = new Testketianglianxin ();
Fr.setsize (500, 300);
Fr.setlocationrelativeto (NULL);
Fr.setdefaultcloseoperation (Jframe.exit_on_close);
Fr.setvisible (TRUE);
}
}

Learn the Java window Basic Operation boring writing

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.