欢迎来到天天文库
浏览记录
ID:55952914
大小:23.50 KB
页数:5页
时间:2020-06-18
《Java技术————创建窗口.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、importjava.awt.Container;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.FocusEvent;importjava.awt.event.FocusListener;importjavax.swing.AbstractListModel;importjavax.swing.ButtonGroup;importjavax.swing.JButton;import
2、javax.swing.JComboBox;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JList;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JPasswordField;importjavax.swing.JRadioButton;importjavax.swing.JScrollPane;importjavax.swing.JTextField;importjavax
3、.swing.SwingConstants;importjavax.swing.WindowConstants;publicclassRegisterextendsJFrameimplementsActionListener,FocusListener{privatestaticfinalStringADD="ADD";privatestaticfinalStringCANCEL="ADD";privatestaticfinallongserialVersionUID=4573735051740981321L;privateJRadioButtonman;priv
4、ateJRadioButtonwoman;privateJTextFieldname_jf;privateJPasswordFieldpassword1_jf;privateJPasswordFieldpassword2_jf;privateJComboBoxeducation_cb;privateJListhobby_jl;privateJButtonsubmit;privateJButtoncancel;privateJPanelpanel1;String[]str={"大学","专科","高中"};String[]str1={"跑步","看书","打球"};
5、privateButtonGroupbg=newButtonGroup();publicstaticvoidmain(String[]args){newRegister();}publicRegister(){Containercon=getContentPane();setTitle("注册");setLayout(newGridLayout(10,8,8,8));con.add(newJLabel("用户名:",SwingConstants.CENTER));name_jf=newJTextField(8);con.add(name_jf);con.add(n
6、ewJLabel("密 码:",0));password1_jf=newJPasswordField(18);con.add(password1_jf);con.add(newJLabel("确认密码:",0));password2_jf=newJPasswordField(18);con.add(password2_jf);password2_jf.addFocusListener(this);con.add(newJLabel("性别:",0));woman=newJRadioButton();man=newJRadioButton();bg.add(man)
7、;bg.add(woman);woman.setSelected(true);woman.setText("女");man.setText("男");panel1=newJPanel();panel1.add(woman);panel1.add(man);con.add(panel1);con.add(newJLabel("学历:",0));education_cb=newJComboBox(str);con.add(education_cb);con.add(newJLabel("爱好:",0));hobby_jl=newJList(str1);con.add(
8、hobby
此文档下载收益归作者所有