📄 registerframe.java~1~
字号:
package register;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JRadioButton;
import javax.swing.JComboBox;
import javax.swing.ButtonGroup;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author 任炳林
* @version 1.0
*/
public class RegisterFrame extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
JLabel lbllogin = new JLabel();
JTextField txtlogin = new JTextField();
JLabel lblpwd = new JLabel();
JLabel lblpwd1 = new JLabel();
JLabel lblsex = new JLabel();
JLabel lblname = new JLabel();
JLabel lbltype = new JLabel();
JLabel lblclass = new JLabel();
JButton btnok = new JButton();
JTextField txtpwd = new JTextField();
JTextField txtpwd1 = new JTextField();
JRadioButton rbtmale = new JRadioButton();
JRadioButton rbtfemale = new JRadioButton();
JTextField txtname = new JTextField();
JRadioButton rbttea = new JRadioButton();
JRadioButton rbtstu = new JRadioButton();
JComboBox cmbclass = new JComboBox();
ButtonGroup buttonGroup1 = new ButtonGroup();
ButtonGroup buttonGroup2 = new ButtonGroup();
public RegisterFrame() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
this.setSize(400,450);
this.setVisible(true);
lbllogin.setText("登录名称");
lbllogin.setBounds(new Rectangle(50, 43, 102, 34));
btnok.addActionListener(new RegisterFrame_btnok_actionAdapter(this));
this.getContentPane().add(lbllogin);
cmbclass.setBounds(new Rectangle(188, 322, 155, 29));
rbtstu.setText("学生");
rbtstu.setBounds(new Rectangle(279, 277, 64, 29));
rbttea.setText("教师");
rbttea.setBounds(new Rectangle(188, 277, 68, 27));
txtname.setBounds(new Rectangle(188, 227, 155, 31));
rbtfemale.setText("女");
rbtfemale.setBounds(new Rectangle(278, 185, 69, 28));
rbtmale.setText("男");
rbtmale.setBounds(new Rectangle(191, 185, 70, 29));
txtpwd1.setBounds(new Rectangle(188, 133, 155, 29));
txtpwd.setBounds(new Rectangle(188, 87, 156, 31));
btnok.setBounds(new Rectangle(197, 385, 136, 37));
btnok.setText("提交");
lblclass.setText("所在班级");
lblclass.setBounds(new Rectangle(52, 322, 94, 29));
lbltype.setText("用户身份");
lbltype.setBounds(new Rectangle(52, 277, 99, 32));
lblname.setText("真实姓名");
lblname.setBounds(new Rectangle(52, 227, 99, 32));
lblsex.setText("性别");
lblsex.setBounds(new Rectangle(50, 183, 100, 29));
lblpwd1.setText("确认密码");
lblpwd1.setBounds(new Rectangle(50, 133, 99, 30));
lblpwd.setText("密码");
lblpwd.setBounds(new Rectangle(50, 87, 101, 32));
this.getContentPane().add(txtlogin);
this.getContentPane().add(lblpwd);
this.getContentPane().add(lblpwd1);
this.getContentPane().add(lblsex);
this.getContentPane().add(lblname);
this.getContentPane().add(lbltype);
this.getContentPane().add(txtpwd);
this.getContentPane().add(txtpwd1);
this.getContentPane().add(rbtmale);
this.getContentPane().add(rbtfemale);
this.getContentPane().add(txtname);
this.getContentPane().add(rbttea);
this.getContentPane().add(rbtstu);
this.getContentPane().add(cmbclass);
this.cmbclass.addItem("s277");
this.cmbclass.addItem("s278");
this.cmbclass.addItem("s279");
this.cmbclass.addItem("s280");
this.cmbclass.addItem("s281");
this.cmbclass.addItem("s282");
this.cmbclass.addItem("s283");
this.getContentPane().add(lblclass);
this.getContentPane().add(btnok);
txtlogin.setBounds(new Rectangle(188, 43, 157, 32));
buttonGroup1.add(rbtmale);
buttonGroup1.add(rbtfemale);
buttonGroup2.add(rbttea);
buttonGroup2.add(rbtstu);
}
public static void main(String[] args) {
RegisterFrame registerframe = new RegisterFrame();
}
public void btnok_actionPerformed(ActionEvent e) {
String a=null;
if(this.cmbclass.getSelectedItem().equals("s277"))
{
a="s277";
}
else if(this.cmbclass.getSelectedItem().equals("s278"))
{
a="s278";
}
else if(this.cmbclass.getSelectedItem().equals("s279"))
{
a="s279";
}
else if(this.cmbclass.getSelectedItem().equals("s280"))
{
a="s280";
}
else if(this.cmbclass.getSelectedItem().equals("s281"))
{
a="s281";
}
else if(this.cmbclass.getSelectedItem().equals("s282"))
{
a="s282";
}
else
{
a="s283";
}
String b=null;
if(this.rbtmale.isSelected())
{
b="1";
}
else
{
b="2";
}
String c=null;
if(this.rbtstu.isSelected())
{
c="1";
}
else
{
c="2";
}
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
}
class RegisterFrame_btnok_actionAdapter implements ActionListener {
private RegisterFrame adaptee;
RegisterFrame_btnok_actionAdapter(RegisterFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnok_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -