Experimental thirteen: Window Design

Experimental thirteen: Window Design

code:

package chuangkou;

import java.awt.Font;
import javax.swing.*;

public class p {

static void main public (String [] args) {
// the TODO method for automatically generating stubs
JFrame frame = new JFrame ( " CV "); // create a form
JPanel p = new JPanel (); // Create panel
frame.add (the p-);
frame.setResizable (false); // not drag form
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.setBounds (500,300,560,340);



JTextField Field1 = new new JTextField (); // create a text box
p.add (Field1);
JTextField Field2 = new new JTextField (); // create a text box
p.add (Field2);
JTextField Field3 = new new JTextField (); // create a text box
p.add (Field3);
JTextField Field4 = new new JTextField ( ); // create a text box
p.add (the Field4);


the JLabel the JLabel new new Ll = ( "Name : "); // create labels
p.add (Ll);
the JLabel = new new L2 of the JLabel (" Gender : ");
p.add (L2 of);
the JLabel new new L3 = the JLabel (" Professional : ");
p.add (L3);
the JLabel new new L4 = the JLabel ( " age :");
p.add (L4);
the JLabel = new new L5 of the JLabel ( " interest :");
p.add (L5 of);
the JLabel = new new L6 of the JLabel ( " national : ");
p.add (L6);
the JLabel = new new L7 the JLabel (" Birthplace : ");
p.add (L7);

JRadioButton r1 = new new JRadioButton (" male "); // create a single box
JRadioButton r2 = new JRadioButton ( " F ");
JRadioButton r3=new JRadioButton("Network Engineering "); // create a single box
JRadioButton r4 = new JRadioButton (" network engineering ");
JRadioButton r5 = new new JRadioButton (" Software Engineering "); // create a single box


ButtonGroup group1 = new ButtonGroup (); // create a group, r1 and r2 together
the ButtonGroup the ButtonGroup new new group2 = ();
group1.add (r1);
group1.add (r2);
group2.add (R3);
group2.add (R4);
group2 .add (R5);
p.add (R1);
p.add (R2);
p.add (R3);
p.add (R4);
p.add (R5);
frame.add (P);


a JCheckBox box1 = new JCheckBox ( " basketball "); // create a check box
JCheckBox box2 = new JCheckBox ( " football");
A JCheckBox BOX3 a JCheckBox new new = (" volleyball ");
a JCheckBox box4 a JCheckBox new new = (" badminton "); 
p.add (box1);
p.add (BOX2);
p.add (BOX3);
p.add ( box4);
frame.add (P);

p.setLayout (null); // custom component position

L1.setBounds (110,35,250,25);
L1.setFont (new new the Font ( " bold ", Font.BOLD, 15 )); // set assembly position
L2.setBounds (110,60,90,30);
L2.setFont (new new the Font ( " bold ", Font.BOLD, 15));
L3.setBounds (110,170,340,35);
L3 .setFont (new Font ( " bold ", Font.BOLD, 15));
L4.setBounds (110,140,140,25);
L4.setFont (new new the Font ( " bold ", Font.BOLD,15));
L5.setBounds(100,210,140,25);
L5.setFont(new Font("黑体",Font.BOLD,15));
L6.setBounds(110,115,340,25);
L6.setFont(new Font("黑体",Font.BOLD,15));
L7.setBounds(110,90,340,25);
L7.setFont(new Font("黑体",Font.BOLD,15));

r1.setBounds(200,60,90,30);
r2.setBounds(300,60,110,30);
r3.setBounds(170,172,110,40);
r4.setBounds(280,172,115,40);
r5.setBounds(390,172,130,40);

box1.setBounds (170,210,100,25);
box2.setBounds (270,210,100,25);
box3.setBounds (370,210,100,25);
box4.setBounds (470,210,100,25);

Field1.setBounds (170,35,250,22);
Field2.setBounds (170,140,250,22);
Field3.setBounds (170,90,250,22);
Field4.setBounds (170,115,250,22); 

frame.setVisible (to true); // set the status display window

}

}

 Experience:

  1. Learn how to use the various components of the graphical interface through the experiment, managing to create components of the various function buttons
  2. How to build a framework, and then join the panel frame, and the label and components to join the panel, you also need more practice.

 

Guess you like

Origin www.cnblogs.com/MWH0979/p/11073237.html