📄 insertdialog.java
字号:
package studentinfosystem.zhouzijie;
import java.awt.*;
import javax.swing.*;
import com.borland.dbswing.JdbTextField;
import java.awt.Rectangle;
import com.borland.dbswing.JdbRadioButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* <p>Title: 学生管理信息系统</p>
*
* <p>Description: 学生管理信息系统数据版本</p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: 广东工业大学</p>
*
* @author 周子杰
* @version 1.0
*/
public class InsertDialog extends JDialog {
JdbTextField jdbTextField1 = new JdbTextField();
JdbTextField jdbTextField2 = new JdbTextField();
JdbRadioButton jdbRadioButton1 = new JdbRadioButton();
JdbRadioButton jdbRadioButton2 = new JdbRadioButton();
JdbTextField jdbTextField3 = new JdbTextField();
JdbTextField jdbTextField4 = new JdbTextField();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
public InsertDialog(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public InsertDialog() {
this(MainFrame.mainframe, "InsertDialog", true);
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(null);
ButtonGroup bg=new ButtonGroup() ;
jdbTextField1.setColumnName("sno");
jdbTextField1.setBounds(new Rectangle(96, 19, 136, 20));
jdbTextField2.setColumnName("name");
jdbTextField2.setBounds(new Rectangle(96, 46, 136, 20));
jdbRadioButton1.setText("男");
jdbRadioButton1.setBounds(new Rectangle(104, 72, 53, 23));
jdbRadioButton2.setText("女");
jdbRadioButton2.setBounds(new Rectangle(159, 72, 73, 23));
jdbTextField3.setColumnName("birthday");
jdbTextField3.setBounds(new Rectangle(96, 101, 136, 20));
jdbTextField4.setColumnName("department");
jdbTextField4.setBounds(new Rectangle(96, 136, 136, 20));
jLabel1.setText("学号:");
jLabel1.setBounds(new Rectangle(36, 20, 85, 15));
jLabel2.setText("姓名:");
jLabel2.setBounds(new Rectangle(36, 47, 42, 15));
jLabel3.setText("性别:");
jLabel3.setBounds(new Rectangle(36, 76, 57, 15));
jLabel4.setText("出生年月:");
jLabel4.setBounds(new Rectangle(36, 104, 82, 15));
jLabel5.setText("院系名称:");
jLabel5.setBounds(new Rectangle(36, 137, 81, 15));
jdbTextField1.setDataSet(MainFrame.queryDataSet1);
jdbTextField2.setDataSet(MainFrame.queryDataSet1);
jdbTextField3.setDataSet(MainFrame.queryDataSet1);
jdbTextField4.setDataSet(MainFrame.queryDataSet1);
jdbRadioButton1.setDataSet(MainFrame.queryDataSet1);
jdbRadioButton2.setDataSet(MainFrame.queryDataSet1);
this.setTitle("插入操作");
jButton1.setBounds(new Rectangle(41, 173, 81, 23));
jButton1.setText("插入");
jButton1.addActionListener(new InsertDialog_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(153, 173, 81, 23));
jButton2.setText("完成");
jButton2.addActionListener(new InsertDialog_jButton2_actionAdapter(this));
jdbRadioButton1.setButtonGroup(bg);
jdbRadioButton2.setButtonGroup(bg);
jdbRadioButton1.setColumnName("sex");
jdbRadioButton2.setColumnName("sex");
jdbRadioButton1.setSelectedDataValue("男");
jdbRadioButton2.setSelectedDataValue("女");
this.getContentPane().add(jLabel1);
this.getContentPane().add(jLabel2);
this.getContentPane().add(jLabel3);
this.getContentPane().add(jLabel4);
this.getContentPane().add(jLabel5);
this.getContentPane().add(jdbTextField3);
this.getContentPane().add(jdbTextField4);
this.getContentPane().add(jdbTextField1);
this.getContentPane().add(jdbTextField2);
this.getContentPane().add(jdbRadioButton1);
this.getContentPane().add(jdbRadioButton2);
this.getContentPane().add(jButton1);
this.getContentPane().add(jButton2);
this.setSize(300,300);
Dimension sreenSize=Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize=this.getSize();
if(frameSize.height>sreenSize.width){
frameSize.height = sreenSize.height;
}
if(frameSize.width>sreenSize.width){
frameSize.width=sreenSize.width;
}
this.setLocation((sreenSize.width-frameSize.width)/2,
(sreenSize.height-frameSize.height)/2);
this.setVisible(true);
}
//插入新数据
public void jButton1_actionPerformed(ActionEvent e) {
MainFrame.queryDataSet1.saveChanges();
MainFrame.queryDataSet1.insertRow(true);
}
public void jButton2_actionPerformed(ActionEvent e) {
MainFrame.queryDataSet1.refresh();
this.setVisible(false);
}
}
class InsertDialog_jButton2_actionAdapter implements ActionListener {
private InsertDialog adaptee;
InsertDialog_jButton2_actionAdapter(InsertDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class InsertDialog_jButton1_actionAdapter implements ActionListener {
private InsertDialog adaptee;
InsertDialog_jButton1_actionAdapter(InsertDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -