import javaawtBorderLayout;
import javaawtColor;
import javaawtFlowLayout;
import javaawtGridLayout;
import javaawteventActionEvent;
import javaawteventActionListener;
import javaxswingBorderFactory;
import javaxswingJButton;
import javaxswingJFrame;
import javaxswingJLabel;
import javaxswingJPanel;
import javaxswingJTextField;
import javaxswingborderBorder;
public class Test {
private JFrame frame;
private JTextField jid,jname,jsex,jedu,jlike;
private JLabel lid,lname,lsex,ledu,llike;
private JButton ok;
private JButton quit;
public Test(){//用户ID、姓名、性别、学历、爱好
frame=new JFrame("用户注册");
jid=new JTextField(10);
jname=new JTextField(10);
jsex=new JTextField(10);
jedu=new JTextField(10);
jlike=new JTextField(10);
lid=new JLabel("用户id:");
lname=new JLabel("用户名:");
lsex=new JLabel("性别:");
ledu=new JLabel("学历:");
llike=new JLabel("爱好:");
ok=new JButton("注册");
quit=new JButton("取消");
init();
showMe();
addEventHandler();
}
private void addEventHandler() {
quitaddActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
Systemexit(0);
}
});
}
public void init(){
framesetLayout(new BorderLayout(2,2));
Border titled = BorderFactorycreateTitledBorder(BorderFactory
createMatteBorder(5, 5, 5, 5, ColorCYAN));
JPanel center = new JPanel();
centersetBorder(titled);
centersetLayout(new GridLayout(5,2,9,10));
JPanel south=new JPanel();
southsetLayout(new FlowLayout());
centeradd(lid);
centeradd(jid);
centeradd(lname);
centeradd(jname);
centeradd(lsex);
centeradd(jsex);
centeradd(ledu);
centeradd(jedu);
centeradd(llike);
centeradd(jlike);
southadd(ok);
southadd(quit);
frameadd(center,BorderLayoutCENTER);
frameadd(south,BorderLayoutSOUTH);
}
public void showMe(){
framesetLocation(500, 300);
framesetSize(210,280);
framesetResizable(false);//不能拖动大小
framesetVisible(true);
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Test()showMe();
}
}
编程语言Python和Java相比较而言,Python更简单一点。以下内容会详细介绍两款编程语言。
一、编程语言Python
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)