资源简介
关于swing代码操作在四个方面分别进行阐述,简单的进行操作,仅参考作用
代码片段和文件信息
package jdbc;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import javax.swing.*;
/**
* @author: ergouzi
* @date: 2018-05-11
* @description: 可对特定数据库表进行增删改查的图形界面程序
*/
public class Main extends Jframe {
private final int COLUMN = 7;
private final List titleS = Arrays.asList(
“Sid“ “Sname“ “Ssex“ “Sage“ “Sclass“ “Sdept“ “Saddr“);
private Vector> dataModel = new Vector>();
private QueryItem id = new QueryItem(“学号:“ 10);
private QueryItem name = new QueryItem(“姓名:“ 10);
private QueryItem sex = new QueryItem(“性别:“ 5);
private QueryItem2 age = new QueryItem2(“年龄自:“ “到“ 5);
private QueryItem class_ = new QueryItem(“班级:“ 5);
private QueryItem dept = new QueryItem(“系别:“ 5);
private QueryItem addr = new QueryItem(“地址:“ 10);
private JButton queryBtn = new JButton(“查询“);
private JButton saveBtn = new JButton(“修改“);
private JButton insertBtn = new JButton(“添加“);
private JButton deleteBtn = new JButton(“删除“);
private JTextArea textarea = new JTextArea(5 5);
private MyTable table;
private Connection conn;
public static void main(String[] args) throws ClassNotFoundException SQLException {
Main frame = new Main(“二狗子增删改查界面“);
frame.connectToDB();
frame.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
frame.setMinimumSize(new Dimension(750 500));
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setResizable(false);
}
//构造函数,负责创建用户界面
public Main(String title) {
super(title);
Vector titles = new Vector(titleS);
table = new MyTable(dataModel titles);
table.getColumnModel().getColumn(2).setPreferredWidth(30);
table.getColumnModel().getColumn(3).setPreferredWidth(30);
table.getColumnModel().getColumn(5).setPreferredWidth(30);
table.getColumnModel().getColumn(6).setPreferredWidth(150);
JPanel controlPanel = new JPanel();
controlPanel.setLayout(new FlowLayout());
controlPanel.add(id);
controlPanel.add(name);
controlPanel.add(sex);
controlPanel.add(age);
controlPanel.add(class_);
controlPanel.add(dept);
controlPanel.add(addr);
controlPanel.add(queryBtn);
controlPanel.add(saveBtn);
controlPanel.add(insertBtn);
controlPanel.add(deleteBtn);
controlPanel.setPreferredSize(new Dimension(0 130));
J
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-11 22:42 swing增删改查\
目录 0 2018-05-11 22:41 swing增删改查\jdbc\
文件 382 2018-05-11 22:23 swing增删改查\jdbc\.classpath
文件 380 2018-05-11 22:16 swing增删改查\jdbc\.project
目录 0 2018-05-11 22:41 swing增删改查\jdbc\.settings\
文件 598 2018-05-11 22:16 swing增删改查\jdbc\.settings\org.eclipse.jdt.core.prefs
目录 0 2018-05-11 22:41 swing增删改查\jdbc\bin\
目录 0 2018-05-11 22:41 swing增删改查\jdbc\bin\jdbc\
文件 3544 2018-05-11 22:37 swing增删改查\jdbc\bin\jdbc\Main$1.class
文件 2655 2018-05-11 22:37 swing增删改查\jdbc\bin\jdbc\Main$2.class
文件 2975 2018-05-11 22:37 swing增删改查\jdbc\bin\jdbc\Main$3.class
文件 1958 2018-05-11 22:37 swing增删改查\jdbc\bin\jdbc\Main$4.class
文件 6113 2018-05-11 22:37 swing增删改查\jdbc\bin\jdbc\Main.class
文件 510 2018-05-11 22:37 swing增删改查\jdbc\bin\jdbc\MyTable.class
文件 1000 2018-05-11 22:37 swing增删改查\jdbc\bin\jdbc\QueryItem.class
文件 865 2018-05-11 22:37 swing增删改查\jdbc\bin\jdbc\QueryItem2.class
目录 0 2018-05-11 22:41 swing增删改查\jdbc\libs\
文件 999635 2018-05-11 22:23 swing增删改查\jdbc\libs\mysql-connector-java-5.1.44-bin.jar
目录 0 2018-05-11 22:41 swing增删改查\jdbc\src\
目录 0 2018-05-11 22:41 swing增删改查\jdbc\src\jdbc\
文件 12377 2018-05-11 22:37 swing增删改查\jdbc\src\jdbc\Main.java
文件 1277 2018-05-11 22:42 swing增删改查\student.sql
文件 1563 2018-05-11 22:40 swing增删改查\说明.txt
评论
共有 条评论