⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 examtime_dialog.java

📁 包含了7个java经典案例
💻 JAVA
字号:
package student;import java.awt.*;import javax.swing.*;import com.borland.jbcl.layout.*;import com.borland.dbswing.*;import com.borland.dx.sql.dataset.*;import com.borland.dx.dataset.*;import java.awt.event.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class ExamTime_Dialog extends JDialog {  JPanel panel1 = new JPanel();  JPanel jPanel1 = new JPanel();  JLabel jLabel1 = new JLabel();  XYLayout xYLayout2 = new XYLayout();  JdbTextField jdbTextField1 = new JdbTextField();  TableScrollPane tableScrollPane1 = new TableScrollPane();  JdbTable jdbTable1 = new JdbTable();  JButton jButton2 = new JButton();  JButton jButton4 = new JButton();  JButton jButton1 = new JButton();  JButton jButton3 = new JButton();  Database database1 = new Database();  QueryDataSet queryDataSet1 = new QueryDataSet();  Column column1 = new Column();  Column column2 = new Column();  GridBagLayout gridBagLayout1 = new GridBagLayout();  public ExamTime_Dialog(Frame frame, String title, boolean modal) {    super(frame, title, modal);    try {      jbInit();      pack();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  public ExamTime_Dialog() {    this(null, "", false);  }  private void jbInit() throws Exception {    panel1.setLayout(gridBagLayout1);    jPanel1.setBorder(BorderFactory.createEtchedBorder());    jPanel1.setLayout(xYLayout2);    jLabel1.setFont(new java.awt.Font("DialogInput", 0, 12));    jLabel1.setText("考试学期:");    jdbTextField1.setText("");    jdbTextField1.setColumnName("time");    jdbTextField1.setDataSet(queryDataSet1);    jButton2.setText("保存");    jButton2.addActionListener(new ExamTime_Dialog_jButton2_actionAdapter(this));    jButton2.addActionListener(new ExamTime_Dialog_jButton2_actionAdapter(this));    jButton2.addActionListener(new ExamTime_Dialog_jButton2_actionAdapter(this));    jButton2.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton4.setText("返回");    jButton4.addActionListener(new ExamTime_Dialog_jButton4_actionAdapter(this));    jButton4.addActionListener(new ExamTime_Dialog_jButton4_actionAdapter(this));    jButton4.addActionListener(new ExamTime_Dialog_jButton4_actionAdapter(this));    jButton4.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton1.setFont(new java.awt.Font("DialogInput", 0, 12));    jButton1.setText("增加");    jButton1.addActionListener(new ExamTime_Dialog_jButton1_actionAdapter(this));    jButton1.addActionListener(new ExamTime_Dialog_jButton1_actionAdapter(this));    jButton1.addActionListener(new ExamTime_Dialog_jButton1_actionAdapter(this));    jButton3.setText("删除");    jButton3.addActionListener(new ExamTime_Dialog_jButton3_actionAdapter(this));    jButton3.addActionListener(new ExamTime_Dialog_jButton3_actionAdapter(this));    jButton3.addActionListener(new ExamTime_Dialog_jButton3_actionAdapter(this));    jButton3.setFont(new java.awt.Font("DialogInput", 0, 12));    database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:student", "", "", false, "sun.jdbc.odbc.JdbcOdbcDriver"));    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select * from examtime;", null, true, Load.ALL));    column1.setCaption("编号");    column1.setColumnName("ID");    column1.setDataType(com.borland.dx.dataset.Variant.INT);    column1.setTableName("examtime");    column1.setServerColumnName("ID");    column1.setSqlType(4);    column2.setCaption("考试学期");    column2.setColumnName("time");    column2.setDataType(com.borland.dx.dataset.Variant.STRING);    column2.setPrecision(24);    column2.setTableName("examtime");    column2.setServerColumnName("time");    column2.setSqlType(12);    queryDataSet1.setColumns(new Column[] {column1, column2});    this.setResizable(false);    this.setTitle("考试学期设置");    jdbTable1.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);    jdbTable1.setDataSet(queryDataSet1);    getContentPane().add(panel1);    panel1.add(jPanel1,  new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 21, 0, 0), 22, 16));    jPanel1.add(jLabel1,   new XYConstraints(9, 20, -1, -1));    jPanel1.add(jdbTextField1,    new XYConstraints(89, 18, 154, -1));    panel1.add(tableScrollPane1,  new GridBagConstraints(0, 1, 1, 3, 1.0, 1.0            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(13, 21, 24, 0), -197, -275));    panel1.add(jButton1,  new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(40, 24, 0, 23), 13, 0));    panel1.add(jButton2,  new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(16, 25, 0, 23), 13, 0));    panel1.add(jButton3,  new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(20, 25, 0, 23), 13, 0));    panel1.add(jButton4,  new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(20, 26, 40, 23), 13, 0));    tableScrollPane1.getViewport().add(jdbTable1, null);  }  void jButton1_actionPerformed(ActionEvent e) {    queryDataSet1.insertRow(false);  }  void jButton2_actionPerformed(ActionEvent e) {    try{       queryDataSet1.post();       queryDataSet1.saveChanges();       queryDataSet1.refresh();     }catch(Exception ex){       queryDataSet1.refresh();       JOptionPane.showMessageDialog(this,"注册失败!","提示",JOptionPane.ERROR_MESSAGE);     }  }  void jButton3_actionPerformed(ActionEvent e) {    try{      queryDataSet1.deleteRow();      queryDataSet1.post();      queryDataSet1.saveChanges();      queryDataSet1.refresh();    }catch(Exception ex){      queryDataSet1.refresh();      JOptionPane.showMessageDialog(this,"删除失败","提示",JOptionPane.ERROR_MESSAGE);    }  }  void jButton4_actionPerformed(ActionEvent e) {    this.dispose();  }}class ExamTime_Dialog_jButton1_actionAdapter implements java.awt.event.ActionListener {  ExamTime_Dialog adaptee;  ExamTime_Dialog_jButton1_actionAdapter(ExamTime_Dialog adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class ExamTime_Dialog_jButton2_actionAdapter implements java.awt.event.ActionListener {  ExamTime_Dialog adaptee;  ExamTime_Dialog_jButton2_actionAdapter(ExamTime_Dialog adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}class ExamTime_Dialog_jButton3_actionAdapter implements java.awt.event.ActionListener {  ExamTime_Dialog adaptee;  ExamTime_Dialog_jButton3_actionAdapter(ExamTime_Dialog adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton3_actionPerformed(e);  }}class ExamTime_Dialog_jButton4_actionAdapter implements java.awt.event.ActionListener {  ExamTime_Dialog adaptee;  ExamTime_Dialog_jButton4_actionAdapter(ExamTime_Dialog adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton4_actionPerformed(e);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -