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

📄 modifywin.java

📁 这是一个用java编写的发音电子词典
💻 JAVA
字号:
/* * ModifyWin.java * * Created on 2007年12月17日, 上午11:22 * * 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 ModifyWin extends JFrame implements ActionListener{        /** Creates a new instance of AddWin */    JTextField 修改汉语解释_文本条,修改英语单词_文本条;    JButton modifybtn,cancelbtn;    Connection Con=null;    Statement Stmt=null;    public ModifyWin()     {        super("修改单词");        this.setBounds(250,250, 250, 200);        this.setVisible(true);        修改英语单词_文本条=new JTextField(20);        修改汉语解释_文本条=new JTextField(20);        JPanel p1=new JPanel();        p1.add(new JLabel("输入要修改的单词:"));                p1.add(修改英语单词_文本条);        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("")||修改汉语解释_文本条.getText().equals(""))                 JOptionPane.showMessageDialog(this,"修改的单词或解释不能为空!","警告",JOptionPane.WARNING_MESSAGE);            else             {                try                {                    modify_word();                }                catch(SQLException ee){}            }        }        else if(e.getSource()==cancelbtn)            this.dispose();    }        public void modify_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()+"'",s2="'"+修改汉语解释_文本条.getText().trim()+"'";                 String temp="UPDATE  表1 SET 解释="+s2+"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 + -