import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.*;
public class mainfram extends JFrame {//继承JFrame
public mainfram() {
initComponents();
}
private void button1ActionPePerformed(ActionEvent e){//butteon1的监听事件
dispose();//释放图形界面资源
new addword().setVisible(true);
}
private void button4ActionPerformed(ActionEvent e) {//注册button4监听事件
String word=textField1.getText().toString();
test test = new test();
String[][] strings = test.selectBydanci(textField1.getText());
if(strings==null){
JOptionPane.showMessageDialog(null, "该单词不存在!", "提示", JOptionPane.WARNING_MESSAGE);
}else {
new chaxun(textField1.getText()).setVisible(true);
}
}
private void button5ActionPerformed(ActionEvent e) {//注册button5监听事件
new all().setVisible(true);
}
private void button6ActionPerformed(ActionEvent e) {//注册button5监听事件
new dim().setVisible(true);
}
private void button8ActionPerformed(ActionEvent e) {//注册button8监听事件
dispose();//释放图形界面资源
}
private void initComponents() {//在使用GUI工具设计GUI界面时系统自动生成的方法。 其功能是在界面添加各个组件,并为它们注册监听器
String[] clos = new String[]{"单词ID","英文","中文"};
button1 = new JButton();
button2 = new JButton();
button3 = new JButton();
button4 = new JButton();
button5 = new JButton();
button6 = new JButton();
textField1 = new JTextField();
label1 = new JLabel();
JScrollPane jScrollPane = new JScrollPane();
test test = new test();
String[][] userList = test.test();
//创建表格
JTable table = new JTable(userList,clos);
table.setRowSelectionAllowed(true);
jScrollPane.setViewportView(table);
button8 = new JButton();
// this
setFont(new Font("楷体", Font.BOLD, 16));
Container contentPane = getContentPane();
contentPane.setLayout(null);
//添加按钮
button1.setText("添加单词");//按钮名字
button1.setForeground(Color.red);//按钮颜色
button1.setFont(new Font("楷体", Font.BOLD, 14));//字体
button1.addActionListener(e -> button1ActionPePerformed(e));//按钮点击事件
contentPane.add(button1);//将按钮添加到面板
button1.setBounds(0, 35, 125, button1.getPreferredSize().height);//按钮位置
//修改按钮
button2.setText("修改单词");
button2.setForeground(Color.red);
button2.setFont(new Font("楷体", Font.BOLD, 14));
button2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {//接口ActionEvent里面定义一个方法,所有用到的类 都要重写这个方法
int i = table.getSelectedRow()+1;
if(i>0){
String valueAt = (String)table.getValueAt(i-1, 0);//先将Object类型转换为String类型
System.out.println(valueAt);
dispose();
//再通过Integer.parseInt(valueAt)将String类型的valueAt转换为int类型传给修改方法
new xiugai(Integer.parseInt(valueAt)).setVisible(true);
}else {
JOptionPane.showMessageDialog(null, "请选择一行!", "提示", JOptionPane.WARNING_MESSAGE);
}
}
});
contentPane.add(button2);
button2.setBounds(0, 80, 125, button2.getPreferredSize().height);
//删除按钮
button3.setText("删除单词");
button3.setForeground(Color.red);
button3.setFont(new Font("楷体", Font.BOLD, 14));
button3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {//接口ActionEvent里面定义一个方法,所有用到的类 都要重写这个方法
int i = table.getSelectedRow()+1;
if(i>0){
try{
myconnection m=new myconnection();
Connection con=m.connection();
String sql1="delete from wor where id='"+i+"'";
PreparedStatement ps=con.prepareStatement(sql1);
int rs=ps.executeUpdate(sql1);
if(rs==0){
JOptionPane.showMessageDialog(null, "删除失败!", "提示", JOptionPane.WARNING_MESSAGE);
}else{
dispose();
JOptionPane.showMessageDialog((Component) null, "删除成功!", "提示", -1);
new mainfram().setVisible(true);
}
}catch(Exception w){
w.printStackTrace();
}
}else {
JOptionPane.showMessageDialog(null, "请选择一行!", "提示", JOptionPane.WARNING_MESSAGE);
}
}
});
contentPane.add(button3);
button3.setBounds(0, 125, 125, button3.getPreferredSize().height);
//查询单词 标签
button4.setText("查询单词");
button4.setForeground(Color.red);
button4.setFont(new Font("楷体", Font.BOLD, 14));
button4.addActionListener(e -> button4ActionPerformed(e));//查询单词的点击事件
contentPane.add(button4);
button4.setBounds(430, 35, 125, button4.getPreferredSize().height);
contentPane.add(textField1);
textField1.setBounds(180, 35, 250, 28);
//查看全部 按钮
button5.setText("查看全部");
button5.setFont(new Font("楷体", Font.BOLD, 14));
button5.setForeground(Color.red);
button5.addActionListener(e -> button5ActionPerformed(e));
contentPane.add(button5);
button5.setBounds(0, 165, 125, button5.getPreferredSize().height);
//查看全部 按钮
button6.setText("索引");
button6.setFont(new Font("楷体", Font.BOLD, 14));
button6.setForeground(Color.red);
button6.addActionListener(e -> button6ActionPerformed(e));
contentPane.add(button6);
button6.setBounds(0, 205, 125, button6.getPreferredSize().height);
//退出系统 按钮
button8.setText("退出系统");
button8.setFont(new Font("楷体", Font.BOLD, 14));
button8.setForeground(Color.red);
button8.addActionListener(e -> button8ActionPerformed(e));//按钮的点击事件
contentPane.add(button8);
button8.setBounds(0, 245, 125, button8.getPreferredSize().height);
//简易单词薄系统 标签
label1.setText("简易单词薄系统");
label1.setForeground(Color.red);
label1.setFont(new Font("楷体", Font.BOLD, 22));
contentPane.add(label1);
label1.setBounds(250, 5, 210, label1.getPreferredSize().height);
contentPane.add(jScrollPane);
jScrollPane.setBounds(130, 65, 500, 350);
{
Dimension preferredSize = new Dimension();//设置容器大小
for(int i = 0; i < contentPane.getComponentCount(); i++) {
Rectangle bounds = contentPane.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.he
没有合适的资源?快使用搜索试试~ 我知道了~
基于Java技术的英汉互译词典
共19个文件
java:9个
xml:4个
jar:3个
需积分: 5 7 下载量 164 浏览量
2022-07-09
05:38:43
上传
评论 3
收藏 2.66MB ZIP 举报
温馨提示
名称:基于Java英汉互译词典 技术:Java 环境:IDEA、mysql 包内容:英汉互译词典源码、mysql文件Word.sql、jar包
资源详情
资源评论
资源推荐
收起资源包目录
Java电子英汉词典.zip (19个子文件)
word.sql 3KB
电子英汉词典.源码
src
myconnection.java 1KB
dim.java 3KB
test.java 7KB
chaxun.java 2KB
show.java 3KB
addword.java 5KB
all.java 3KB
mysql-connector-java-5.1.32-bin.jar 946KB
mainfram.java 9KB
xiugai.java 6KB
.idea
misc.xml 276B
modules.xml 261B
workspace.xml 7KB
.gitignore 256B
libraries
mysql_connector_java_5_1_32_bin.xml 256B
mysql-connector-java-5.1.32-bin.jar 946KB
keshe22.iml 535B
out
production
keshe22
mysql-connector-java-5.1.32-bin.jar 946KB
共 19 条
- 1
After_666
- 粉丝: 7
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0