Java AWT支持下的编程
发布网友
发布时间:2022-06-02 01:59
我来回答
共1个回答
热心网友
时间:2023-10-24 09:41
/**
*
*/
package com.dianziermu.els.ui;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
* 学生信息
* @author 点子二木
* @date 2009-5-20
* @version 1.0
*/
public class TestMainFrame extends JFrame {
private static final int DEFAULT_WIDTH = 600;
private static final int DEFAULT_HIGHT = 700;
/**
* @param args
*/
public static void main(String[] args) {
TestMainFrame frame = new TestMainFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public TestMainFrame() {
setTitle("学生信息");
setSize(DEFAULT_WIDTH, DEFAULT_HIGHT);
////////form中加入页面属性//////////
JLabel lbName = new JLabel("姓名");
JTextField tfName = new JTextField(20);
JLabel lbSex = new JLabel("性别");
JRadioButton rbSex = new JRadioButton("sex");
JRadioButtonMenuItem rbmMale = new JRadioButtonMenuItem("男");
JRadioButtonMenuItem rbmFeMale = new JRadioButtonMenuItem("女");
rbSex.add(rbmMale);
rbSex.add(rbmFeMale);
JLabel lbNO = new JLabel("学号");
JTextField tfNO= new JTextField(20);
JLabel lbID = new JLabel("身份证号");
JTextField tfID= new JTextField(20);
JLabel lbRemark = new JLabel("备注");
JTextArea tfRemark= new JTextArea(20,30);
JButton btnNew = new JButton("新增");
JButton btnExit = new JButton("取消");
Panel panel = new Panel();
panel.add(lbName);
panel.add(tfName);
panel.add(lbSex);
panel.add(rbSex);
panel.add(lbNO);
panel.add(tfNO);
panel.add(lbID);
panel.add(tfID);
panel.add(lbRemark);
panel.add(tfRemark);
panel.add(btnNew);
panel.add(btnExit);
add(panel);
}
}
class Panel extends JPanel {
}