JAVA --- comprehensive window layout exercises

Source: Internet
Author: User

[Java] view plaincopy
/*
Time:
2012-10-18
Author:
Smoke
Program Design:
Implement a program output window
Program explanation:
This program is mainly used for setting familiar layout,
Familiarize yourself with the usage and features of some la s through this program
*/
 
Import javax. swing .*;
Import java. awt .*;
Class Day1018_Frame
{
Public static void main (String [] args)
{
JFrame f = new JFrame ("My window program! ");
Container c = f. getContentPane ();
// FlowLayout l = new FlowLayout ();
// BorderLayout l = new BorderLayout ();
// GridLayout l = new GridLayout (7,1 );

GridBagLayout l = new GridBagLayout ();

C. setLayout (l );
C. add (new JLabel ("Please select your answer :"));
C. add (new JCheckBox ("A: Getting Russian mage "));
C. add (new JCheckBox ("B: good places around the Internet "));
C. add (new JCheckBox ("C: when delivery is received "));
C. add (new JCheckBox ("D: The location is not "));
String str [] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday "};
JComboBox B = new JComboBox (str );
C. add (B );
String str2 [] = {"Mathematics", "Chinese", "English", "physics", "chemistry "};
JList ls = new JList (str2 );
C. add (ls );
F. setdefaclocloseoperation (JFrame. EXIT_ON_CLOSE );
F. setVisible (true );
// F. setSize (400,300 );
F. pack ();
}
}

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.