📄 useoutdialog.java
字号:
package bar;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.text.*;
import java.sql.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class useOutDialog extends JDialog {
JPanel panel1 = new JPanel();
BorderLayout borderLayout1 = new BorderLayout();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField jTextField2 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JComboBox jComboBox1 = new JComboBox();
public useOutDialog(mainFrame frame, String title, boolean modal) {
super(frame, title, modal);
Frame1 = frame;
this.setLocation(250,200);
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public useOutDialog() {
this(null, "", false);
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(borderLayout1);
panel1.setPreferredSize(new Dimension(300, 200));
panel1.setLayout(null);
jLabel1.setFont(new java.awt.Font("Serif", 0, 16));
jLabel1.setText("机 器 号:");
jLabel1.setBounds(new Rectangle(50, 30, 80, 25));
jComboBox1.setBounds(new Rectangle(130, 30, 100, 25));
jLabel2.setFont(new java.awt.Font("Serif", 0, 16));
jLabel2.setText("结束时间:");
jLabel2.setBounds(new Rectangle(50, 100, 80, 25));
java.util.Date today = new java.util.Date();
SimpleDateFormat HMFromat = new SimpleDateFormat("HH:mm");
String nowTime = HMFromat.format(today);
jTextField2.setText(nowTime);
jTextField2.setBounds(new Rectangle(130, 100, 100, 25));
jButton1.setBounds(new Rectangle(60, 150, 70, 25));
jButton1.setText("确定");
jButton1.addActionListener(new useOutDialog_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(150, 150, 70, 25));
jButton2.setText("重置");
jButton2.addActionListener(new useOutDialog_jButton2_actionAdapter(this));
panel1.add(jLabel1, null);
panel1.add(jLabel2, null);
panel1.add(jTextField2, null);
panel1.add(jButton1, null);
panel1.add(jButton2, null);
panel1.add(jComboBox1, null);
this.getContentPane().add(panel1, BorderLayout.CENTER);
con = barConnect.getconn();
Statement stmt = con.createStatement();
ResultSet boxRs = stmt.executeQuery("select * from event where EndTime is NULL order by ComputerID");
jComboBox1.addItem("");
while(boxRs.next()){
jComboBox1.addItem(boxRs.getString("ComputerID"));
}
boxRs.close();
}
void jButton2_actionPerformed(ActionEvent e) {
jComboBox1.setSelectedIndex(0);
jTextField2.setText("");
}
void jButton1_actionPerformed(ActionEvent e) {
try {
Statement insertStmt = con.createStatement();
String insertString =
"update event set EndTime ='"+jTextField2.getText()+":00' where ComputerID = " +
Integer.parseInt(jComboBox1.getSelectedItem().toString()) +
" and EndTime is NULL";
insertStmt.executeUpdate(insertString);
Frame1.SetComputerID(Integer.parseInt(jComboBox1.getSelectedItem().toString()));
con.close();
this.hide();
}
catch (SQLException ex) {
Frame1.SetComputerID(0);
}
}
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
Frame1.SetComputerID(0);
this.hide();
}
}
private mainFrame Frame1;
private Connection con;
}
class useOutDialog_jButton2_actionAdapter implements java.awt.event.ActionListener {
useOutDialog adaptee;
useOutDialog_jButton2_actionAdapter(useOutDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class useOutDialog_jButton1_actionAdapter implements java.awt.event.ActionListener {
useOutDialog adaptee;
useOutDialog_jButton1_actionAdapter(useOutDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -