📄 gridbaglayoutapplet.java
字号:
import java.awt.*;
import javax.swing.*;
public class GridBagLayoutApplet extends JApplet {
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
GridBagLayout gridBagLayout1 = new GridBagLayout();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JTextField jTextField2 = new JTextField();
JPanel jPanel3 = new JPanel();
JRadioButton jRadioButton1 = new JRadioButton();
JRadioButton jRadioButton2 = new JRadioButton();
JTextField jTextField3 = new JTextField();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JTextField jTextField4 = new JTextField();
JLabel jLabel8 = new JLabel();
JTextField jTextField5 = new JTextField();
JLabel jLabel9 = new JLabel();
JTextField jTextField6 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
ButtonGroup btng1=new ButtonGroup();
//Applet初始
public void init() {
try {
myInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//组件初始设定
private void myInit() throws Exception {
this.setSize(new Dimension(449, 176));
this.getContentPane().setLayout(borderLayout1);
jPanel1.setLayout(gridBagLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 16));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("在线登录作业");
jLabel2.setText("用户名称");
jLabel3.setText("身份证登记号");
jLabel4.setText("性别");
jLabel5.setText("出生年月");
jRadioButton1.setText("男");
jRadioButton2.setText("女");
jLabel6.setText("联络电话");
jLabel7.setText("日:");
jLabel8.setText("夜:");
jLabel9.setText("联络地址");
jButton1.setText("立即登录");
jButton2.setText("离开");
this.getContentPane().add(jPanel2, BorderLayout.SOUTH);
jPanel2.add(jButton1, null);
jPanel2.add(jButton2, null);
btng1.add(jButton1);
btng1.add(jButton2);
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jTextField2, new GridBagConstraints(5, 0, 1, 2, 0.0, 0.0
,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(-1, 0, 1, 20), 84, 0));
jPanel1.add(jRadioButton1, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
jPanel1.add(jLabel4, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
jPanel1.add(jLabel2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0, 21, 0, 0), 19, 0));
jPanel1.add(jTextField1, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0
,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, -1, 0, 3), 119, 0));
jPanel1.add(jTextField3, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 85, 0));
jPanel1.add(jRadioButton2, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
jPanel1.add(jLabel6, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
jPanel1.add(jLabel7, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
jPanel1.add(jTextField4, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 82, 0));
jPanel1.add(jLabel3, new GridBagConstraints(3, 0, 2, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 18, 0));
jPanel1.add(jLabel5, new GridBagConstraints(3, 2, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
jPanel1.add(jTextField5, new GridBagConstraints(4, 3, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 92, 0));
jPanel1.add(jLabel9, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
jPanel1.add(jLabel8, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
jPanel1.add(jTextField6, new GridBagConstraints(1, 4, 5, 2, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 240, 0));
this.getContentPane().add(jPanel3, BorderLayout.NORTH);
jPanel3.add(jLabel1, null);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -