3个回答
展开全部
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.Border;
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() {
quit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
public void init(){
frame.setLayout(new BorderLayout(2,2));
Border titled = BorderFactory.createTitledBorder(BorderFactory
.createMatteBorder(5, 5, 5, 5, Color.CYAN));
JPanel center = new JPanel();
center.setBorder(titled);
center.setLayout(new GridLayout(5,2,9,10));
JPanel south=new JPanel();
south.setLayout(new FlowLayout());
center.add(lid);
center.add(jid);
center.add(lname);
center.add(jname);
center.add(lsex);
center.add(jsex);
center.add(ledu);
center.add(jedu);
center.add(llike);
center.add(jlike);
south.add(ok);
south.add(quit);
frame.add(center,BorderLayout.CENTER);
frame.add(south,BorderLayout.SOUTH);
}
public void showMe(){
frame.setLocation(500, 300);
frame.setSize(210,280);
frame.setResizable(false);//不能拖动大小
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Test().showMe();
}
}
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.Border;
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() {
quit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
public void init(){
frame.setLayout(new BorderLayout(2,2));
Border titled = BorderFactory.createTitledBorder(BorderFactory
.createMatteBorder(5, 5, 5, 5, Color.CYAN));
JPanel center = new JPanel();
center.setBorder(titled);
center.setLayout(new GridLayout(5,2,9,10));
JPanel south=new JPanel();
south.setLayout(new FlowLayout());
center.add(lid);
center.add(jid);
center.add(lname);
center.add(jname);
center.add(lsex);
center.add(jsex);
center.add(ledu);
center.add(jedu);
center.add(llike);
center.add(jlike);
south.add(ok);
south.add(quit);
frame.add(center,BorderLayout.CENTER);
frame.add(south,BorderLayout.SOUTH);
}
public void showMe(){
frame.setLocation(500, 300);
frame.setSize(210,280);
frame.setResizable(false);//不能拖动大小
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Test().showMe();
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你好。
如果只是注册,不包括数据持久化的话,我可以给你写出来。
如果只是注册,不包括数据持久化的话,我可以给你写出来。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询