Browse Source

Java swing 界面

master
lixl1 3 years ago
parent
commit
5ae3c826cc
  1. 572
      src/main/java/com/insigma/ui/SwingFrame.java

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

@ -0,0 +1,572 @@
package com.qggwy;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.JButton;
import java.awt.Panel;
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;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.awt.event.ActionEvent;
import javax.swing.JCheckBox;
import javax.swing.JProgressBar;
import javax.swing.Timer;
import javax.swing.JTextPane;
import java.awt.Component;
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;
/**
* 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;
}
}
}catch(Exception e) {
System.out.println(e);
}
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
SwingFrame frame = new SwingFrame();
frame.setTitle("系统工具"); //设置显示窗口标题
// frame.setSize(1600,400);//设置显示窗口大小
// frame.getContentPane().setBackground(Color.blue);//设置显示窗体颜色
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置窗口是否可以关闭
frame.setBounds(100, 100, 773, 459);
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.");
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
* @throws IOException
*/
public SwingFrame() throws IOException {
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
tabbedPane.setBounds(5, 5, 745, 402);
tabbedPane.setBackground(Color.WHITE);
tabbedPane.setFont(new Font("微软雅黑", Font.PLAIN, 15));
contentPane.add(tabbedPane);
JPanel memoryPanel = new JPanel();//调整内存面板
memoryPanel.setBorder(UIManager.getBorder("Button.border"));
memoryPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
memoryPanel.setForeground(Color.GRAY);
memoryPanel.setBackground(new Color(220, 220, 220));
tabbedPane.addTab("调整内存", null, memoryPanel, null);
memoryPanel.setLayout(null);
JLabel lblNewLabel = new JLabel("调整内存");
lblNewLabel.setBounds(60, 31, 125, 34);
lblNewLabel.setForeground(Color.RED);
lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 30));
memoryPanel.add(lblNewLabel);
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);
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);
JButton btnNewButton_1 = new JButton("保存");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
// btnNewButton_1.setContentAreaFilled(false);//按钮设置为透明
// btnNewButton_1.setBorder(BorderFactory.createRaisedBevelBorder());//设置凸起来的按钮
// btnNewButton_1.setBorder(BorderFactory.createLoweredBevelBorder()); //设置凹起来的按钮
// btnNewButton_1.setBorderPainted(false);//去掉按钮的边框的设置
// String path = "C:\\Users\\86177\\Desktop\\www.png";
// File file = new File(path);
// 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.setBackground(new Color(220, 220, 220));
tabbedPane.addTab("数据库备份", null, backupsPanel, null);
backupsPanel.setLayout(null);
JLabel lblNewLabel_12 = new JLabel("数据库备份");
lblNewLabel_12.setBounds(32, 13, 114, 28);
lblNewLabel_12.setFont(new Font("微软雅黑", Font.PLAIN, 20));
backupsPanel.add(lblNewLabel_12);
JLabel label_10 = new JLabel("数据库还原");
label_10.setBounds(459, 13, 105, 28);
label_10.setFont(new Font("微软雅黑", Font.PLAIN, 20));
backupsPanel.add(label_10);
String strMsg1 = "当系统因突发情况无法正常启动时,可以进行数据备份,确保因系统异常情况导致数据丢失。";
String strMsg = "<html><body>" + strMsg1 + "<br><body></html>";
JLabel lblNewLabel_13 = new JLabel(strMsg);
lblNewLabel_13.setBounds(32, 39, 238, 107);
lblNewLabel_13.setFont(new Font("微软雅黑", Font.PLAIN, 16));
backupsPanel.add(lblNewLabel_13);
String strMsg3 = "备份数据库中所有的数据表,即安装路径下的data文件";
String strMsg4 = "(D:\\hzb2021\\mysql\\data)";
String strMsgData = "<html><body>" + strMsg3 + "<br>" + strMsg4 + "<body></html>";
JLabel lblNewLabel_14 = new JLabel(strMsgData);
lblNewLabel_14.setBounds(32, 131, 238, 96);
lblNewLabel_14.setFont(new Font("微软雅黑", Font.PLAIN, 16));
backupsPanel.add(lblNewLabel_14);
String strMsg5 = "数据备份默认至保存安装路径下,即(D:\\hzb2021),保存格式zip文件";
String strMsgData1 = "<html><body>" + strMsg5 + "<br><body></html>";
JLabel lblNewLabel_15 = new JLabel(strMsgData1);
lblNewLabel_15.setBounds(32, 223, 228, 96);
lblNewLabel_15.setFont(new Font("微软雅黑", Font.PLAIN, 16));
backupsPanel.add(lblNewLabel_15);
JButton btnNewButton_3 = new JButton("数据库备份");
btnNewButton_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnNewButton_3.setBounds(32, 316, 113, 27);
backupsPanel.add(btnNewButton_3);
JLabel label_11 = new JLabel("<html><body>数据库还原将覆盖当前系统中所有人为产生的数据,不可恢复,需谨慎操作。<br><body></html>");
label_11.setBounds(382, 55, 238, 74);
label_11.setFont(new Font("微软雅黑", Font.PLAIN, 16));
backupsPanel.add(label_11);
JLabel label_12 = new JLabel("<html><body>为确保当前系统的安全,需要输入当前系统管理员密码才可以进行数据库还原。<br><body></html>");
label_12.setBounds(382, 149, 238, 74);
label_12.setFont(new Font("微软雅黑", Font.PLAIN, 16));
backupsPanel.add(label_12);
JButton button = new JButton("数据库还原");
button.setBounds(451, 316, 113, 27);
backupsPanel.add(button);
JLabel lblNewLabel_16 = new JLabel("注:当系统遇到极端情况导致无法登陆时,系统卸载可进行数据库备份,重装或升级之后进行数据库还原。");
lblNewLabel_16.setFont(new Font("微软雅黑", Font.PLAIN, 13));
lblNewLabel_16.setBounds(14, 366, 620, 18);
backupsPanel.add(lblNewLabel_16);
Panel upgradePanel = new Panel();//系统升级面板
upgradePanel.setBackground(new Color(220, 220, 220));
tabbedPane.addTab("系统升级", null, upgradePanel, null);
upgradePanel.setLayout(null);
JLabel lblNewLabel_8 = new JLabel("安装包/升级包下载");
lblNewLabel_8.setFont(new Font("微软雅黑", Font.PLAIN, 20));
lblNewLabel_8.setBounds(47, 47, 181, 28);
upgradePanel.add(lblNewLabel_8);
final JLabel lblNewLabel_9 = new JLabel("下载地址:https://www.12371.cn/zgrjxz/gwywx/");
lblNewLabel_9.setFont(new Font("微软雅黑", Font.PLAIN, 18));
lblNewLabel_9.setBounds(57, 88, 420, 18);
upgradePanel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e){ //鼠标点击事件
@SuppressWarnings("unused")
URI uri = null;
try {
try {
uri = new URI("https://www.12371.cn/zgrjxz/gwywx/");
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
Desktop dtp = Desktop.getDesktop();
if(Desktop.isDesktopSupported() && dtp.isSupported(Desktop.Action.BROWSE)) {
try {
dtp.browse(uri);
} catch (IOException e1) {
e1.printStackTrace();
}
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
public void mouseEntered(MouseEvent e) { //鼠标移入事件
lblNewLabel_9.setForeground(Color.red);
}
public void mouseExited(MouseEvent e) { //鼠标移出事件
lblNewLabel_9.setForeground(Color.blue);
}
});
upgradePanel.add(lblNewLabel_9);
JLabel lblNewLabel_10 = new JLabel("客服电话:400-8600-797-1、400-9608-590-5。");
lblNewLabel_10.setFont(new Font("微软雅黑", Font.PLAIN, 20));
lblNewLabel_10.setBounds(47, 161, 462, 28);
upgradePanel.add(lblNewLabel_10);
JLabel lblNewLabel_11 = new JLabel("业务咨询、商务洽谈。");
lblNewLabel_11.setFont(new Font("宋体", Font.PLAIN, 18));
lblNewLabel_11.setBounds(57, 202, 278, 18);
upgradePanel.add(lblNewLabel_11);
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.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("停止修复");
btnNewButton_2.setBounds(495, 65, 113, 27);
startRepairPanel.add(btnNewButton_2);
JProgressBar progressBar = new JProgressBar();
// MyJProgressBar progressBar = new MyJProgressBar();
progressBar.setBounds(57, 65, 412, 27);
// 设置进度的 最小值 和 最大值
progressBar.setMinimum(MIN_PROGRESS);
progressBar.setMaximum(MAX_PROGRESS);
// 设置当前进度值
progressBar.setValue(currentProgress);
// 绘制百分比文本(进度条中间显示的百分数)
progressBar.setStringPainted(true);
// 添加进度改变通知
progressBar.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
System.out.println("当前进度值: " + progressBar.getValue() + "; " +
"进度百分比: " + progressBar.getPercentComplete());
}
});
// 添加到内容面板
startRepairPanel.add(progressBar);
JSeparator separator_2 = new JSeparator();
separator_2.setBounds(56, 105, 564, 5);
separator_2.setBackground(Color.LIGHT_GRAY);
startRepairPanel.add(separator_2);
JLabel lblNewLabel_7 = new JLabel("更新情况");
lblNewLabel_7.setFont(new Font("微软雅黑", Font.PLAIN, 18));
lblNewLabel_7.setBounds(57, 121, 78, 18);
startRepairPanel.add(lblNewLabel_7);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(57, 152, 539, 232);
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);
JButton btnNewButton_4 = new JButton("返回");
btnNewButton_4.setBounds(14, 13, 113, 27);
btnNewButton_4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
panel.setLayout(null);
panel.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);
JLabel lblNewLabel_18 = new JLabel("存储目录:");
lblNewLabel_18.setBounds(71, 90, 85, 27);
lblNewLabel_18.setFont(new Font("微软雅黑", Font.PLAIN, 15));
panel.add(lblNewLabel_18);
JButton btnNewButton_5 = new JButton("更改");
btnNewButton_5.setBounds(414, 92, 113, 24);
panel.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);
JButton btnNewButton_6 = new JButton("开始备份");
btnNewButton_6.setBounds(206, 357, 113, 27);
panel.add(btnNewButton_6);
textField_5 = new JTextField("D:\\hzb2022");
textField_5.setFont(new Font("微软雅黑", Font.PLAIN, 15));
textField_5.setBounds(170, 92, 245, 24);
panel.add(textField_5);
textField_5.setColumns(10);
new Timer(500, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
currentProgress++;
if (currentProgress > MAX_PROGRESS) {
currentProgress = MIN_PROGRESS;
}
progressBar.setValue(currentProgress);
progressBar.setForeground(Color.BLUE);
}
}).start();
}
@Override
public void actionPerformed(ActionEvent e) {
}
}
Loading…
Cancel
Save