Browse Source

javaswing系统工具

master
lixl1 3 years ago
parent
commit
ab07169283
  1. 10
      src/main/java/com/insigma/HyToolApplication.java
  2. 576
      src/main/java/com/insigma/ui/SwingFrame.java
  3. BIN
      src/main/java/com/insigma/ui/favicon.jpg

10
src/main/java/com/insigma/HyToolApplication.java

@ -3,6 +3,7 @@ package com.insigma;
import cn.hutool.db.Session;
import com.insigma.config.AppCfg;
import com.insigma.demos.SwingSet2;
import com.insigma.ui.SwingFrame;
import com.insigma.utils.DbUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
@ -42,10 +43,11 @@ public class HyToolApplication {
AppCfg.is32Bit = AppCfg.OSArch.equals(propertiesValue);
AppCfg.BROWSER = loadProperties.getProperty("hy.browser");
SwingUtilities.invokeLater(() -> {
log.info("正在启动GUI =======================>>> 成功!");
SwingSet2.main(args);
});
// SwingUtilities.invokeLater(() -> {
// log.info("正在启动GUI =======================>>> 成功!");
// SwingSet2.main(args);
// });
SwingFrame.run();
Session session = DbUtil.getSession(url, usr, pwd, drive);
log.info("获取{}连接,进行操作!", session);
session.close();

576
src/main/java/com/insigma/ui/SwingFrame.java

@ -1,9 +1,22 @@
package com.insigma.ui;
import com.insigma.service.impl.WindowsTomcatMysql;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import java.awt.EventQueue;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
@ -11,14 +24,14 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.JButton;
import java.awt.Panel;
import java.awt.Toolkit;
import javax.swing.JTabbedPane;
import java.awt.Font;
import javax.swing.JTextField;
import java.awt.Color;
import java.awt.Desktop;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.UIManager;
@ -31,51 +44,51 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.awt.event.ActionEvent;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JProgressBar;
import javax.swing.Timer;
import javax.swing.JTextPane;
import javax.swing.filechooser.FileFilter;
import java.awt.Component;
/**
* @author BeiJing-GWY
*/
@Slf4j
public class SwingFrame extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
private JTextField textField_4;
private final int MIN_PROGRESS = 0;
private final int MAX_PROGRESS = 100;
private int currentProgress = MIN_PROGRESS;
private JTextField textField_5;
private JLabel lblNewLabel_6;
private JTextField textField;
private JPanel startRepairPanel;
private JPanel repairPanel;
private JPanel backupsPanel;
private JPanel startBackupPanel;
private JPanel startRestorePanel;
private JTabbedPane tabbedPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
public static void run() {
// try {
// for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
// if ("Nimbus".equals(info.getName())) {
// javax.swing.UIManager.setLookAndFeel(info.getClassName());
// break;
// }
// }
// }catch(Exception e) {
// System.out.println(e);
// }
try {//设置界面样式 Look And Feel
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
log.error("启动发生异常:", e);
e.printStackTrace();
}
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
SwingFrame frame = new SwingFrame();
@ -83,16 +96,9 @@ public class SwingFrame extends JFrame implements ActionListener {
// frame.setSize(1600,400);//设置显示窗口大小
// frame.getContentPane().setBackground(Color.blue);//设置显示窗体颜色
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置窗口是否可以关闭
frame.setBounds(100, 100, 773, 459);
frame.setBounds(100, 100, 910, 580);
frame.setVisible(true);
java.net.URL imgURL =SwingFrame.class.getResource("favicon.jpg");
ImageIcon arrowIcon = null;
if (imgURL != null) {
arrowIcon = new ImageIcon(imgURL);
frame.setIconImage(arrowIcon.getImage());
} else {
JOptionPane.showMessageDialog(frame, "Icon image not found.");
}
frame.setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\JavaSwing\\src\\main\\java\\com\\insigma\\ui\\favicon.jpg"));
} catch (Exception e) {
e.printStackTrace();
}
@ -111,12 +117,73 @@ public class SwingFrame extends JFrame implements ActionListener {
setContentPane(contentPane);
contentPane.setLayout(null);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
tabbedPane.setBounds(5, 5, 745, 402);
tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
tabbedPane.setBounds(5, 5, 903, 530);
tabbedPane.setBackground(Color.WHITE);
tabbedPane.setFont(new Font("微软雅黑", Font.PLAIN, 15));
contentPane.add(tabbedPane);
repairPanel = new JPanel();//系统优化面板
repairPanel.setForeground(Color.GRAY);
repairPanel.setBackground(new Color(220, 220, 220));
tabbedPane.addTab("系统优化", null, repairPanel, null);
repairPanel.setLayout(null);
JLabel label_5 = new JLabel("系统优化");
label_5.setBounds(42, 35, 120, 40);
label_5.setForeground(Color.RED);
label_5.setFont(new Font("微软雅黑", Font.PLAIN, 30));
repairPanel.add(label_5);
JButton btnNewButton = new JButton("开始优化");
btnNewButton.setFont(new Font("微软雅黑", Font.PLAIN, 15));
btnNewButton.setBounds(617, 63, 113, 40);
btnNewButton.addActionListener(this);
repairPanel.add(btnNewButton);
JLabel label_6 = new JLabel("通过重启服务、清除缓存等操作可以有效解决大部分系统运行问题。");
label_6.setBounds(42, 88, 544, 18);
label_6.setFont(new Font("微软雅黑", Font.PLAIN, 15));
repairPanel.add(label_6);
JSeparator separator_1 = new JSeparator();
separator_1.setBackground(Color.LIGHT_GRAY);
separator_1.setBounds(27, 116, 715, 5);
repairPanel.add(separator_1);
JCheckBox chckbxNewCheckBox = new JCheckBox("重启服务",true);
chckbxNewCheckBox.setBackground(new Color(220, 220, 220));
chckbxNewCheckBox.setBounds(53, 130, 162, 27);
chckbxNewCheckBox.setFont(new Font("微软雅黑", Font.PLAIN, 18));
repairPanel.add(chckbxNewCheckBox);
JLabel lblNewLabel_5 = new JLabel("当系统运行慢时,可操作重启应用进行系统重启Tomcat、MySql。");
lblNewLabel_5.setBounds(77, 166, 573, 18);
lblNewLabel_5.setFont(new Font("微软雅黑", Font.PLAIN, 15));
repairPanel.add(lblNewLabel_5);
JCheckBox checkBox_1 = new JCheckBox("清除缓存",true);
checkBox_1.setBackground(new Color(220, 220, 220));
checkBox_1.setBounds(53, 205, 253, 27);
checkBox_1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
repairPanel.add(checkBox_1);
JLabel label_8 = new JLabel("当系统内存不够,运行缓慢或无法正常升级时,可操作清除缓存和应用缓存。");
label_8.setBounds(77, 241, 514, 18);
label_8.setFont(new Font("微软雅黑", Font.PLAIN, 15));
repairPanel.add(label_8);
JLabel lblNewLabel_2 = new JLabel("临时测试图片");
lblNewLabel_2.setIcon(new ImageIcon("D:\\icon\\favicon.jpg"));
lblNewLabel_2.setBounds(34, 309, 240, 185);
repairPanel.add(lblNewLabel_2);
JButton btnNewButton_8 = new JButton("打开服务管理器");
btnNewButton_8.setFont(new Font("微软雅黑", Font.PLAIN, 15));
btnNewButton_8.setBounds(582, 132, 148, 40);
btnNewButton_8.addActionListener(this);
repairPanel.add(btnNewButton_8);
JPanel memoryPanel = new JPanel();//调整内存面板
memoryPanel.setBorder(UIManager.getBorder("Button.border"));
memoryPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
@ -131,87 +198,80 @@ public class SwingFrame extends JFrame implements ActionListener {
lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 30));
memoryPanel.add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("根据具体系统运行可设置应用内容、数据库内容的大小。");
JLabel lblNewLabel_1 = new JLabel("根据具体系统运行情况,可以选择最佳运行状态。");
lblNewLabel_1.setBounds(60, 75, 375, 18);
lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 15));
memoryPanel.add(lblNewLabel_1);
JSeparator separator = new JSeparator();
separator.setBackground(Color.LIGHT_GRAY);
separator.setBounds(60, 106, 531, 5);
separator.setBackground(Color.LIGHT_GRAY);
memoryPanel.add(separator);
JLabel lblNewLabel_2 = new JLabel("应用内存");
lblNewLabel_2.setBounds(60, 124, 80, 18);
lblNewLabel_2.setFont(new Font("微软雅黑", Font.PLAIN, 20));
memoryPanel.add(lblNewLabel_2);
JLabel lblNewLabel_3 = new JLabel("非堆区初始内存分配大小");
lblNewLabel_3.setBackground(new Color(221, 160, 221));
lblNewLabel_3.setBounds(82, 165, 175, 18);
lblNewLabel_3.setFont(new Font("微软雅黑", Font.PLAIN, 15));
memoryPanel.add(lblNewLabel_3);
JLabel label = new JLabel("堆区最大内存分配上限");
label.setBounds(82, 196, 156, 18);
label.setFont(new Font("微软雅黑", Font.PLAIN, 15));
memoryPanel.add(label);
JLabel label_1 = new JLabel("初始内存分配大小");
label_1.setBounds(82, 227, 156, 18);
label_1.setFont(new Font("微软雅黑", Font.PLAIN, 15));
memoryPanel.add(label_1);
JLabel label_2 = new JLabel("最大内存分配上限");
label_2.setBounds(82, 258, 156, 18);
label_2.setFont(new Font("微软雅黑", Font.PLAIN, 15));
memoryPanel.add(label_2);
textField = new JTextField();
textField.setBounds(255, 163, 86, 24);
memoryPanel.add(textField);
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setBounds(255, 196, 86, 24);
textField_1.setColumns(10);
memoryPanel.add(textField_1);
textField_2 = new JTextField();
textField_2.setBounds(255, 227, 86, 24);
textField_2.setColumns(10);
memoryPanel.add(textField_2);
textField_3 = new JTextField();
textField_3.setBounds(255, 256, 86, 24);
textField_3.setColumns(10);
memoryPanel.add(textField_3);
JLabel lblNewLabel_4 = new JLabel("最大可设置到1024MB");
lblNewLabel_4.setFont(new Font("微软雅黑", Font.PLAIN, 15));
lblNewLabel_4.setBounds(355, 166, 163, 18);
memoryPanel.add(lblNewLabel_4);
JLabel label_3 = new JLabel("数据库内存");
label_3.setFont(new Font("微软雅黑", Font.PLAIN, 20));
label_3.setBounds(60, 307, 100, 24);
memoryPanel.add(label_3);
JLabel label_4 = new JLabel("数据库内存大小");
label_4.setFont(new Font("微软雅黑", Font.PLAIN, 15));
label_4.setBounds(82, 344, 156, 18);
memoryPanel.add(label_4);
textField_4 = new JTextField();
textField_4.setColumns(10);
textField_4.setBounds(255, 342, 86, 24);
memoryPanel.add(textField_4);
String strMsgBtn = "高性能内存配置";
String strMsgBtn1 = "大于16G内存的电脑可调整到高性能配置";
String msgBtn = "<html><body>" + strMsgBtn + "<br>"+strMsgBtn1+"<body></html>";
JButton btnNewButton_7 = new JButton(msgBtn);
btnNewButton_7.setBounds(72, 138, 329, 59);
btnNewButton_7.setFont(new Font("微软雅黑", Font.PLAIN, 15));
btnNewButton_7.addActionListener(new ActionListener() {
@SneakyThrows
public void actionPerformed(ActionEvent e) {
new WindowsTomcatMysql().setDbSize(200000);
new WindowsTomcatMysql().setMwSize(200000);
}
});
memoryPanel.add(btnNewButton_7);
String strMsgBtn16G = "16G内存配置方案";
String strMsgBtn16G1 = "大于16G内存的电脑可调整到高性能配置";
String msgBtn16G = "<html><body>" + strMsgBtn16G + "<br>"+strMsgBtn16G1+"<body></html>";
JButton button_1 = new JButton(msgBtn16G);
button_1.setBounds(72, 227, 329, 59);
button_1.setFont(new Font("微软雅黑", Font.PLAIN, 15));
button_1.addActionListener(new ActionListener() {
@SneakyThrows
public void actionPerformed(ActionEvent e) {
new WindowsTomcatMysql().setDbSize(160000);
new WindowsTomcatMysql().setMwSize(160000);
}
});
memoryPanel.add(button_1);
String strMsgBtn8G = "8G内存配置方案";
String strMsgBtn8G1 = "大于8G内存的电脑可调整到高性能配置";
String msgBtn8G = "<html><body>" + strMsgBtn8G + "<br>"+strMsgBtn8G1+"<body></html>";
JButton button_2 = new JButton(msgBtn8G);
button_2.setBounds(72, 314, 329, 59);
button_2.setFont(new Font("微软雅黑", Font.PLAIN, 15));
button_2.addActionListener(new ActionListener() {
@SneakyThrows
public void actionPerformed(ActionEvent e) {
new WindowsTomcatMysql().setDbSize(80000);
new WindowsTomcatMysql().setMwSize(80000);
}
});
memoryPanel.add(button_2);
String strMsgBtn4G = "4G内存配置方案";
String strMsgBtn4G1 = "大于4G内存的电脑可调整到高性能配置";
String msgBtn4G = "<html><body>" + strMsgBtn4G + "<br>"+strMsgBtn4G1+"<body></html>";
JButton button_3 = new JButton(msgBtn4G);
button_3.setBounds(72, 399, 329, 59);
button_3.setFont(new Font("微软雅黑", Font.PLAIN, 15));
button_3.addActionListener(new ActionListener() {
@SneakyThrows
public void actionPerformed(ActionEvent e) {
new WindowsTomcatMysql().setDbSize(40000);
new WindowsTomcatMysql().setMwSize(40000);
}
});
memoryPanel.add(button_3);
JButton btnNewButton_1 = new JButton("保存");
btnNewButton_1.setBounds(566, 472, 113, 40);
btnNewButton_1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//暂定保存内容
}
});
// btnNewButton_1.setContentAreaFilled(false);//按钮设置为透明
@ -223,81 +283,9 @@ public class SwingFrame extends JFrame implements ActionListener {
// Image image = ImageIO.read(file);
// btnNewButton_1.setIcon(new ImageIcon(image.getScaledInstance(50, 50, image.SCALE_DEFAULT)));
btnNewButton_1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
btnNewButton_1.setBounds(500, 344, 113, 40);
memoryPanel.add(btnNewButton_1);
JPanel repairPanel = new JPanel();//数据修复面板
repairPanel.setForeground(Color.GRAY);
repairPanel.setBackground(new Color(220, 220, 220));
tabbedPane.addTab("数据修复", null, repairPanel, null);
repairPanel.setLayout(null);
JLabel label_5 = new JLabel("系统修复");
label_5.setBounds(42, 35, 120, 40);
label_5.setForeground(Color.RED);
label_5.setFont(new Font("微软雅黑", Font.PLAIN, 30));
repairPanel.add(label_5);
JButton btnNewButton = new JButton("开始修复");
btnNewButton.setBounds(504, 42, 113, 40);
repairPanel.add(btnNewButton);
JLabel label_6 = new JLabel("通过数据清洗等操作可以有效解决系统功能异常问题");
label_6.setBounds(42, 76, 375, 18);
label_6.setFont(new Font("微软雅黑", Font.PLAIN, 15));
repairPanel.add(label_6);
JSeparator separator_1 = new JSeparator();
separator_1.setBackground(Color.LIGHT_GRAY);
separator_1.setBounds(27, 100, 590, 5);
repairPanel.add(separator_1);
JCheckBox chckbxNewCheckBox = new JCheckBox("修复数据库数据");
chckbxNewCheckBox.setBackground(new Color(220, 220, 220));
chckbxNewCheckBox.setBounds(53, 130, 162, 27);
chckbxNewCheckBox.setFont(new Font("微软雅黑", Font.PLAIN, 18));
repairPanel.add(chckbxNewCheckBox);
JLabel lblNewLabel_5 = new JLabel("机构信息管理、人员信息管理、数据校核、信息系统查询等。");
lblNewLabel_5.setBounds(77, 166, 405, 18);
lblNewLabel_5.setFont(new Font("微软雅黑", Font.PLAIN, 15));
repairPanel.add(lblNewLabel_5);
JCheckBox checkBox = new JCheckBox("修复系统管理数据");
checkBox.setBackground(new Color(220, 220, 220));
checkBox.setBounds(53, 193, 173, 27);
checkBox.setFont(new Font("微软雅黑", Font.PLAIN, 18));
repairPanel.add(checkBox);
JLabel label_7 = new JLabel("角色管理、用户管理、日志管理、系统参数配置等。");
label_7.setBounds(77, 229, 345, 18);
label_7.setFont(new Font("微软雅黑", Font.PLAIN, 15));
repairPanel.add(label_7);
JCheckBox checkBox_1 = new JCheckBox("修复统计专用信息管理数据");
checkBox_1.setBackground(new Color(220, 220, 220));
checkBox_1.setBounds(53, 256, 253, 27);
checkBox_1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
repairPanel.add(checkBox_1);
JLabel label_8 = new JLabel("信息表、校核、使用情况、人员对比等。");
label_8.setBounds(72, 290, 270, 18);
label_8.setFont(new Font("微软雅黑", Font.PLAIN, 15));
repairPanel.add(label_8);
JCheckBox checkBox_2 = new JCheckBox("修复年报统计数据");
checkBox_2.setBackground(new Color(220, 220, 220));
checkBox_2.setBounds(53, 331, 253, 27);
checkBox_2.setFont(new Font("微软雅黑", Font.PLAIN, 18));
repairPanel.add(checkBox_2);
JLabel label_9 = new JLabel("统计报表、校核、报表说明等。");
label_9.setFont(new Font("微软雅黑", Font.PLAIN, 15));
label_9.setBounds(72, 366, 270, 18);
repairPanel.add(label_9);
Panel backupsPanel = new Panel();//数据库备份面板
backupsPanel = new JPanel();//数据库备份、还原面板
backupsPanel.setBackground(new Color(220, 220, 220));
tabbedPane.addTab("数据库备份", null, backupsPanel, null);
backupsPanel.setLayout(null);
@ -335,12 +323,8 @@ public class SwingFrame extends JFrame implements ActionListener {
backupsPanel.add(lblNewLabel_15);
JButton btnNewButton_3 = new JButton("数据库备份");
btnNewButton_3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
btnNewButton_3.setBounds(32, 316, 113, 27);
btnNewButton_3.setBounds(32, 351, 113, 27);
btnNewButton_3.addActionListener(this);
backupsPanel.add(btnNewButton_3);
JLabel label_11 = new JLabel("<html><body>数据库还原将覆盖当前系统中所有人为产生的数据,不可恢复,需谨慎操作。<br><body></html>");
@ -354,12 +338,13 @@ public class SwingFrame extends JFrame implements ActionListener {
backupsPanel.add(label_12);
JButton button = new JButton("数据库还原");
button.setBounds(451, 316, 113, 27);
button.setBounds(451, 351, 113, 27);
button.addActionListener(this);
backupsPanel.add(button);
JLabel lblNewLabel_16 = new JLabel("注:当系统遇到极端情况导致无法登陆时,系统卸载可进行数据库备份,重装或升级之后进行数据库还原。");
lblNewLabel_16.setFont(new Font("微软雅黑", Font.PLAIN, 13));
lblNewLabel_16.setBounds(14, 366, 620, 18);
lblNewLabel_16.setFont(new Font("微软雅黑", Font.PLAIN, 15));
lblNewLabel_16.setBounds(14, 494, 710, 18);
backupsPanel.add(lblNewLabel_16);
Panel upgradePanel = new Panel();//系统升级面板
@ -377,7 +362,6 @@ public class SwingFrame extends JFrame implements ActionListener {
lblNewLabel_9.setBounds(57, 88, 420, 18);
upgradePanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e){ //鼠标点击事件
@SuppressWarnings("unused")
URI uri = null;
@ -400,11 +384,9 @@ public class SwingFrame extends JFrame implements ActionListener {
}
}
@Override
public void mouseEntered(MouseEvent e) { //鼠标移入事件
lblNewLabel_9.setForeground(Color.red);
}
@Override
public void mouseExited(MouseEvent e) { //鼠标移出事件
lblNewLabel_9.setForeground(Color.blue);
}
@ -422,19 +404,16 @@ public class SwingFrame extends JFrame implements ActionListener {
lblNewLabel_11.setBounds(57, 202, 278, 18);
upgradePanel.add(lblNewLabel_11);
JPanel startRepairPanel = new JPanel();
startRepairPanel = new JPanel();
startRepairPanel.setBackground(new Color(220, 220, 220));
tabbedPane.addTab("开始修复界面", null, startRepairPanel, null);
startRepairPanel.setLayout(null);
lblNewLabel_6 = new JLabel("系统正在数据修复中,建议不要随意随意停止!");
lblNewLabel_6 = new JLabel("系统正在加速优化中,建议不要随意随意操作停止!");
lblNewLabel_6.setBounds(57, 34, 378, 18);
lblNewLabel_6.setForeground(new Color(255, 0, 0));
lblNewLabel_6.setFont(new Font("微软雅黑", Font.PLAIN, 18));
startRepairPanel.add(lblNewLabel_6);
JButton btnNewButton_2 = new JButton("停止修复");
JButton btnNewButton_2 = new JButton("停止优化");
btnNewButton_2.setBounds(495, 65, 113, 27);
startRepairPanel.add(btnNewButton_2);
@ -452,7 +431,7 @@ public class SwingFrame extends JFrame implements ActionListener {
progressBar.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
log.info("当前进度值: " + progressBar.getValue() + "; " +
System.out.println("当前进度值: " + progressBar.getValue() + "; " +
"进度百分比: " + progressBar.getPercentComplete());
}
});
@ -470,101 +449,136 @@ public class SwingFrame extends JFrame implements ActionListener {
startRepairPanel.add(lblNewLabel_7);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(57, 152, 539, 232);
scrollPane.setBounds(57, 152, 539, 338);
startRepairPanel.add(scrollPane);
JTextPane textPane = new JTextPane();
scrollPane.setViewportView(textPane);
JPanel panel = new JPanel();
panel.setBackground(new Color(220, 220, 220));
tabbedPane.addTab("数据库备份", null, panel, null);
startBackupPanel = new JPanel();//执行数据库备份面板
startBackupPanel.setBackground(new Color(220, 220, 220));
JButton btnNewButton_4 = new JButton("返回");
btnNewButton_4.setBounds(14, 13, 113, 27);
btnNewButton_4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
panel.setLayout(null);
panel.add(btnNewButton_4);
btnNewButton_4.setFont(new Font("微软雅黑", Font.PLAIN, 15));
btnNewButton_4.setBounds(14, 13, 113, 35);
btnNewButton_4.addActionListener(this);
startBackupPanel.setLayout(null);
startBackupPanel.add(btnNewButton_4);
JLabel lblNewLabel_17 = new JLabel("数据库备份");
lblNewLabel_17.setBounds(94, 60, 100, 27);
lblNewLabel_17.setFont(new Font("微软雅黑", Font.PLAIN, 20));
panel.add(lblNewLabel_17);
startBackupPanel.add(lblNewLabel_17);
JLabel lblNewLabel_18 = new JLabel("存储目录:");
lblNewLabel_18.setBounds(71, 90, 85, 27);
lblNewLabel_18.setFont(new Font("微软雅黑", Font.PLAIN, 15));
panel.add(lblNewLabel_18);
startBackupPanel.add(lblNewLabel_18);
JButton btnNewButton_5 = new JButton("更改");
btnNewButton_5.setBounds(414, 92, 113, 24);
panel.add(btnNewButton_5);
btnNewButton_5.setFont(new Font("微软雅黑", Font.PLAIN, 15));
btnNewButton_5.setBounds(486, 91, 100, 24);
btnNewButton_5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser jfC = new JFileChooser();
// jfC.setMultiSelectionEnabled(true);//文件是否多选!参数为true或false
jfC.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);//设置文件的打开模式(只能选文件夹)
jfC.setDialogTitle("请选择要上传的文件夹");
int value = jfC.showOpenDialog(SwingFrame.this);
if(value == JFileChooser.APPROVE_OPTION) {
File dirFile = jfC.getSelectedFile();//返回选中的文件
textField_5.setText(dirFile.getAbsolutePath());
}
}
});
startBackupPanel.add(btnNewButton_5);
JLabel lblNewLabel_19 = new JLabel("数据库备份的格式为“zip”");
lblNewLabel_19.setBounds(170, 120, 186, 18);
lblNewLabel_19.setFont(new Font("微软雅黑", Font.PLAIN, 15));
panel.add(lblNewLabel_19);
JLabel label_13 = new JLabel("备份内容:");
label_13.setFont(new Font("微软雅黑", Font.PLAIN, 15));
label_13.setBounds(71, 140, 85, 27);
panel.add(label_13);
JLabel label_14 = new JLabel("基础库");
label_14.setFont(new Font("微软雅黑", Font.PLAIN, 20));
label_14.setBounds(170, 140, 100, 27);
panel.add(label_14);
JLabel label_15 = new JLabel("机构信息管理、人员信息管理、数据校核、信息系统查询等。");
label_15.setFont(new Font("微软雅黑", Font.PLAIN, 15));
label_15.setBounds(170, 160, 412, 27);
panel.add(label_15);
JLabel label_16 = new JLabel("系统管理");
label_16.setFont(new Font("微软雅黑", Font.PLAIN, 20));
label_16.setBounds(170, 190, 100, 27);
panel.add(label_16);
JLabel label_17 = new JLabel("角色管理、用户管理、日志管理、系统参数配置等。");
label_17.setFont(new Font("微软雅黑", Font.PLAIN, 15));
label_17.setBounds(170, 210, 412, 27);
panel.add(label_17);
JLabel label_18 = new JLabel("统计专用信息管理");
label_18.setFont(new Font("微软雅黑", Font.PLAIN, 20));
label_18.setBounds(170, 240, 167, 27);
panel.add(label_18);
JLabel label_19 = new JLabel("信息表、校核、使用情况、人员对比等。");
label_19.setFont(new Font("微软雅黑", Font.PLAIN, 15));
label_19.setBounds(170, 266, 412, 27);
panel.add(label_19);
JLabel label_20 = new JLabel("统计年报");
label_20.setFont(new Font("微软雅黑", Font.PLAIN, 20));
label_20.setBounds(170, 293, 100, 27);
panel.add(label_20);
JLabel label_21 = new JLabel("统计报表、校核、报表说明等。");
label_21.setFont(new Font("微软雅黑", Font.PLAIN, 15));
label_21.setBounds(170, 318, 412, 27);
panel.add(label_21);
startBackupPanel.add(lblNewLabel_19);
JButton btnNewButton_6 = new JButton("开始备份");
btnNewButton_6.setBounds(206, 357, 113, 27);
panel.add(btnNewButton_6);
btnNewButton_6.setFont(new Font("微软雅黑", Font.PLAIN, 15));
btnNewButton_6.setBounds(206, 186, 113, 35);
btnNewButton_6.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
textField_5 = new JTextField("D:\\hzb2022");
}
});
startBackupPanel.add(btnNewButton_6);
textField_5 = new JTextField();
textField_5.setBounds(170, 92, 319, 24);
textField_5.setFont(new Font("微软雅黑", Font.PLAIN, 15));
textField_5.setBounds(170, 92, 245, 24);
panel.add(textField_5);
startBackupPanel.add(textField_5);
textField_5.setColumns(10);
startRestorePanel = new JPanel();
startRestorePanel.setLayout(null);
startRestorePanel.setBackground(new Color(220, 220, 220));
JButton button_4 = new JButton("返回");
button_4.setFont(new Font("微软雅黑", Font.PLAIN, 15));
button_4.setBounds(14, 13, 113, 35);
button_4.addActionListener(this);
startRestorePanel.add(button_4);
JLabel label = new JLabel("数据库还原");
label.setFont(new Font("微软雅黑", Font.PLAIN, 20));
label.setBounds(94, 60, 100, 27);
startRestorePanel.add(label);
JButton button_5 = new JButton("上传文件:");
button_5.setFont(new Font("微软雅黑", Font.PLAIN, 15));
button_5.setBounds(94, 91, 116, 24);
button_5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser jfC = new JFileChooser();
jfC.setFileFilter(new FileFilter() {
@Override
public String getDescription() {
return "ZIP压缩文件(*.zip)";
}
@Override
public boolean accept(File f) {
if(f.getName().toLowerCase().endsWith(".zip")) {
return true;
}
return false;
}
});
// jfC.setMultiSelectionEnabled(true);//文件是否多选!参数为true或false
jfC.setFileSelectionMode(JFileChooser.FILES_ONLY);//设置文件的打开模式(只能选文件夹)
jfC.setDialogTitle("请选择要上传的文件夹");
int value = jfC.showOpenDialog(SwingFrame.this);
if(value == JFileChooser.APPROVE_OPTION) {
File dirFile = jfC.getSelectedFile();//返回选中的文件
textField.setText(dirFile.getAbsolutePath());
}
}
});
startRestorePanel.add(button_5);
JLabel label_2 = new JLabel("数据库备份的格式为“zip”");
label_2.setFont(new Font("微软雅黑", Font.PLAIN, 15));
label_2.setBounds(170, 120, 186, 18);
startRestorePanel.add(label_2);
JButton button_6 = new JButton("开始还原");
button_6.setFont(new Font("微软雅黑", Font.PLAIN, 15));
button_6.setBounds(206, 186, 113, 35);
startRestorePanel.add(button_6);
textField = new JTextField("");
textField.setFont(new Font("微软雅黑", Font.PLAIN, 15));
textField.setColumns(10);
textField.setBounds(207, 91, 330, 24);
startRestorePanel.add(textField);
new Timer(500, new ActionListener() {
@Override
@ -581,6 +595,32 @@ public class SwingFrame extends JFrame implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
String buttonCommand = e.getActionCommand();
if(buttonCommand.equals("打开服务管理器")) {
try{
// Runtime rt = Runtime.getRuntime();runBak
// Process p = rt.exec("cmd.exe /c compmgmt.msc");
new WindowsTomcatMysql().openServer();
}catch (Exception ex){
ex.printStackTrace();
}
}else if(buttonCommand.equals("开始优化")) {
try{
tabbedPane.addTab("开始优化界面", null, startRepairPanel, null);
tabbedPane.setSelectedComponent(startRepairPanel);
new WindowsTomcatMysql().startDbService();
new WindowsTomcatMysql().startDbService();
}catch (Exception ex){
ex.printStackTrace();
}
}else if(buttonCommand.equals("数据库备份")) {
tabbedPane.addTab("数据库备份", null, startBackupPanel, null);
tabbedPane.setSelectedComponent(startBackupPanel);
}else if(buttonCommand.equals("数据库还原")) {
tabbedPane.addTab("数据库还原", null, startRestorePanel, null);
tabbedPane.setSelectedComponent(startRestorePanel);
}else if(buttonCommand.equals("返回")) {
tabbedPane.setSelectedComponent(backupsPanel);
}
}
}

BIN
src/main/java/com/insigma/ui/favicon.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Loading…
Cancel
Save