📄 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) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class useOutDialog extends JDialog { JPanel panel1 = new JPanel(); JLabel jLabel1 = new JLabel(); JComboBox jComboBox1 = new JComboBox(); JLabel jLabel2 = new JLabel(); JTextField jTextField1 = new JTextField(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); private mainFrame Frame1; private Connection con; 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 { panel1.setLayout(null); jLabel1.setFont(new java.awt.Font("Serif", 1, 16)); jLabel1.setHorizontalAlignment(SwingConstants.CENTER); jLabel1.setText("机器号:"); jLabel1.setBounds(new Rectangle(78, 47, 68, 34)); jComboBox1.setBounds(new Rectangle(165, 54, 130, 26)); jLabel2.setFont(new java.awt.Font("Serif", 1, 16)); jLabel2.setText("结束时间:"); jLabel2.setBounds(new Rectangle(70, 141, 92, 31)); java.util.Date today = new java.util.Date(); SimpleDateFormat HMFromat = new SimpleDateFormat("HH:mm"); String nowTime = HMFromat.format(today); jTextField1.setText(nowTime); jTextField1.setBounds(new Rectangle(166, 145, 131, 24)); jButton1.setBounds(new Rectangle(85, 221, 73, 25)); jButton1.setFont(new java.awt.Font("Serif", 0, 12)); jButton1.setText("确定"); jButton1.addActionListener(new useOutDialog_jButton1_actionAdapter(this)); jButton2.setText("重设"); jButton2.addActionListener(new useOutDialog_jButton2_actionAdapter(this)); jButton2.setFont(new java.awt.Font("Serif", 0, 12)); jButton2.setBounds(new Rectangle(239, 219, 73, 25)); panel1.add(jLabel1, null); panel1.add(jLabel2, null); panel1.add(jButton1, null); panel1.add(jComboBox1, null); panel1.add(jTextField1, null); panel1.add(jButton2, null); this.getContentPane().add(panel1, BorderLayout.CENTER); con = barConnect.getconn(); Statement stmt = con.createStatement(); ResultSet boxRs = stmt.executeQuery("select ComputerID from Event where EndTime is NULL order by ComputerID"); jComboBox1.addItem(""); while(boxRs.next()){ jComboBox1.addItem(boxRs.getString("ComputerID")); } boxRs.close(); } void jButton1_actionPerformed(ActionEvent e) { try { Statement insertStmt = con.createStatement(); String insertString = "update event set EndTime ='"+jTextField1.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); } } void jButton2_actionPerformed(ActionEvent e) { jComboBox1.setSelectedIndex(0); jTextField1.setText(""); }}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); }}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); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -