📄 delwin.java
字号:
/* * DelWin.java * * Created on 2007年12月17日, 上午11:32 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */package 电子词典;import java.awt.*;import java.sql.*;import java.awt.event.*;import javax.swing.*;/** * * @author baili */public class DelWin extends JFrame implements ActionListener{ /** Creates a new instance of AddWin */ JTextField 删除英语单词_文本条; JButton modifybtn,cancelbtn; Connection Con=null; Statement Stmt=null; public DelWin() { super("删除单词"); this.setBounds(250,250, 250, 200); this.setVisible(true); 删除英语单词_文本条=new JTextField(20); JPanel p1=new JPanel(); p1.add(new JLabel("输入要删除的单词:")); p1.add(删除英语单词_文本条); modifybtn=new JButton("提交"); cancelbtn=new JButton("取消"); modifybtn.addActionListener(this); cancelbtn.addActionListener(this); p1.add(modifybtn); p1.add(cancelbtn); this.getContentPane().add(p1); this.validate(); } public void actionPerformed(ActionEvent e) { if(e.getSource()==modifybtn) { if(删除英语单词_文本条.getText().equals("")) JOptionPane.showMessageDialog(this,"删除的单词不能为空!","警告",JOptionPane.WARNING_MESSAGE); else { try { delete_word(); } catch(SQLException ee){} } } else if(e.getSource()==cancelbtn) this.dispose(); } public void delete_word()throws SQLException { String cname,ename; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(ClassNotFoundException e){} Con=DriverManager.getConnection("jdbc:odbc:english;","",""); Stmt=Con.createStatement(); ResultSet rs=Stmt.executeQuery("SELECT *FROM 表1"); boolean boo=false; while((boo=rs.next())==true) { ename=rs.getString("单词"); cname=rs.getString("解释"); if(ename.equals(删除英语单词_文本条.getText())) { String s1="'"+删除英语单词_文本条.getText().trim()+"'"; String temp="DELETE FROM 表1 WHERE 单词="+s1; Stmt.executeUpdate(temp); JOptionPane.showMessageDialog(this,"删除成功!","恭喜",JOptionPane.WARNING_MESSAGE); dispose(); } } Con.close(); if(boo==false) { JOptionPane.showMessageDialog(this,"不存在此单词!","警告",JOptionPane.WARNING_MESSAGE); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -