From 81903484338bb9f58e319eb41a2fda4c308e2323 Mon Sep 17 00:00:00 2001 From: lixl1 Date: Fri, 29 Apr 2022 10:12:54 +0800 Subject: [PATCH] =?UTF-8?q?javaswing=E7=B3=BB=E7=BB=9F=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/insigma/ui/SwingFrame.java | 129 +++++++++++-------- 1 file changed, 76 insertions(+), 53 deletions(-) diff --git a/src/main/java/com/insigma/ui/SwingFrame.java b/src/main/java/com/insigma/ui/SwingFrame.java index 76b195c..f8b90f0 100644 --- a/src/main/java/com/insigma/ui/SwingFrame.java +++ b/src/main/java/com/insigma/ui/SwingFrame.java @@ -67,26 +67,21 @@ public class SwingFrame extends JFrame implements ActionListener { * Launch the application. */ 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) { -// e.printStackTrace(); +// 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) { + e.printStackTrace(); + } EventQueue.invokeLater(new Runnable() { public void run() { try { @@ -95,7 +90,7 @@ 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, 910, 580); + frame.setBounds(100, 100, 930, 580); frame.setVisible(true); frame.setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\JavaSwing\\src\\main\\java\\com\\insigma\\ui\\favicon.jpg")); } catch (Exception e) { @@ -117,7 +112,7 @@ public class SwingFrame extends JFrame implements ActionListener { contentPane.setLayout(null); tabbedPane = new JTabbedPane(JTabbedPane.LEFT); - tabbedPane.setBounds(5, 5, 903, 530); + tabbedPane.setBounds(5, 5, 930, 566); tabbedPane.setBackground(Color.WHITE); tabbedPane.setFont(new Font("微软雅黑", Font.PLAIN, 15)); contentPane.add(tabbedPane); @@ -135,8 +130,8 @@ public class SwingFrame extends JFrame implements ActionListener { repairPanel.add(label_5); JButton btnNewButton = new JButton("开始优化"); - btnNewButton.setForeground(Color.WHITE); - btnNewButton.setBackground(new Color(55, 205, 255)); + btnNewButton.setForeground(Color.BLUE); + btnNewButton.setBackground(Color.WHITE); btnNewButton.setFont(new Font("微软雅黑", Font.PLAIN, 20)); btnNewButton.setBorderPainted(false);//去掉按钮的边框的设置 btnNewButton.setBounds(617, 63, 113, 40); @@ -155,29 +150,30 @@ public class SwingFrame extends JFrame implements ActionListener { JCheckBox chckbxNewCheckBox = new JCheckBox("重启服务",true); chckbxNewCheckBox.setBackground(Color.WHITE); - chckbxNewCheckBox.setBounds(53, 130, 162, 27); + chckbxNewCheckBox.setBounds(27, 128, 101, 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.setBounds(24, 164, 446, 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.setBackground(Color.WHITE); + checkBox_1.setBounds(27, 205, 101, 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.setBounds(24, 243, 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); + JLabel lblNewLabel_2 = new JLabel(); + lblNewLabel_2.setFont(new Font("微软雅黑", Font.PLAIN, 15)); + lblNewLabel_2.setText("清理缓存
释放空间"); + lblNewLabel_2.setIcon(new ImageIcon("C:\\Users\\86177\\Desktop\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u6E05\u7406.png")); + lblNewLabel_2.setBounds(658, 134, 120, 67); repairPanel.add(lblNewLabel_2); JLabel lblNewLabel_3 = new JLabel("打开服务管理器"); @@ -193,9 +189,24 @@ public class SwingFrame extends JFrame implements ActionListener { } } }); - lblNewLabel_3.setBounds(164, 127, 140, 31); + lblNewLabel_3.setBounds(128, 125, 140, 31); repairPanel.add(lblNewLabel_3); + JLabel label_9 = new JLabel(); + label_9.setFont(new Font("微软雅黑", Font.PLAIN, 15)); + label_9.setText("提高系统
运行速度"); + label_9.setIcon(new ImageIcon("C:\\Users\\86177\\Desktop\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u8FD0\u884C.png")); + label_9.setBounds(536, 205, 125, 77); + repairPanel.add(label_9); + + JLabel label_13 = new JLabel(); + label_13.setFont(new Font("微软雅黑", Font.PLAIN, 15)); + label_13.setText("重启服务
更新系统"); + label_13.setIcon(new ImageIcon("C:\\Users\\86177\\Desktop\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u91CD\u542F.png")); + label_13.setBounds(536, 129, 125, 77); + repairPanel.add(label_13); + + JPanel memoryPanel = new JPanel();//调整内存面板 memoryPanel.setBorder(UIManager.getBorder("Button.border")); memoryPanel.setAlignmentX(Component.LEFT_ALIGNMENT); @@ -303,8 +314,9 @@ public class SwingFrame extends JFrame implements ActionListener { } }); memoryPanel.add(button_3); + JButton btnNewButton_1 = new JButton("保存"); - btnNewButton_1.setForeground(Color.WHITE); + btnNewButton_1.setForeground(Color.BLUE); btnNewButton_1.setFont(new Font("微软雅黑", Font.PLAIN, 20)); btnNewButton_1.setBackground(new Color(55, 205, 255)); btnNewButton_1.setBorderPainted(false);//去掉按钮的边框的设置 @@ -362,11 +374,6 @@ public class SwingFrame extends JFrame implements ActionListener { lblNewLabel_15.setFont(new Font("微软雅黑", Font.PLAIN, 16)); backupsPanel.add(lblNewLabel_15); -// JButton btnNewButton_3 = new JButton("数据库备份"); -// btnNewButton_3.setBounds(32, 351, 113, 27); -// btnNewButton_3.addActionListener(this); -// backupsPanel.add(btnNewButton_3); - JLabel label_11 = new JLabel("数据库还原将覆盖当前系统中所有人为产生的数据,不可恢复,需谨慎操作。
"); label_11.setBounds(382, 55, 238, 74); label_11.setFont(new Font("微软雅黑", Font.PLAIN, 16)); @@ -491,10 +498,6 @@ public class SwingFrame extends JFrame implements ActionListener { lblNewLabel_6.setFont(new Font("微软雅黑", Font.PLAIN, 18)); startRepairPanel.add(lblNewLabel_6); - - - - JProgressBar progressBar = new JProgressBar(); progressBar.setBackground(Color.WHITE); progressBar.setFont(new Font("微软雅黑", Font.PLAIN, 15)); @@ -529,18 +532,34 @@ public class SwingFrame extends JFrame implements ActionListener { startRepairPanel.add(lblNewLabel_7); JScrollPane scrollPane = new JScrollPane(); - scrollPane.setBounds(57, 152, 539, 338); + scrollPane.setBounds(57, 152, 425, 338); startRepairPanel.add(scrollPane); JTextPane textPane = new JTextPane(); scrollPane.setViewportView(textPane); + JLabel label_14 = new JLabel(); + label_14.setIcon(new ImageIcon("C:\\Users\\86177\\Desktop\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u91CD\u542F.png")); + label_14.setText("重启服务
更新系统"); + label_14.setFont(new Font("微软雅黑", Font.PLAIN, 15)); + label_14.setBounds(496, 152, 125, 77); + startRepairPanel.add(label_14); + + JLabel label_15 = new JLabel(); + label_15.setIcon(new ImageIcon("C:\\Users\\86177\\Desktop\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u6E05\u7406.png")); + label_15.setText("清理缓存
释放空间"); + label_15.setFont(new Font("微软雅黑", Font.PLAIN, 15)); + label_15.setBounds(639, 157, 120, 67); + startRepairPanel.add(label_15); + + JLabel label_16 = new JLabel(); + label_16.setIcon(new ImageIcon("C:\\Users\\86177\\Desktop\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u8FD0\u884C.png")); + label_16.setText("提高系统
运行速度"); + label_16.setFont(new Font("微软雅黑", Font.PLAIN, 15)); + label_16.setBounds(506, 242, 125, 77); + startRepairPanel.add(label_16); + startBackupPanel = new JPanel();//执行数据库备份面板 startBackupPanel.setBackground(Color.WHITE); - - - - - startBackupPanel.setLayout(null); @@ -556,7 +575,9 @@ public class SwingFrame extends JFrame implements ActionListener { JButton btnNewButton_5 = new JButton("更改"); - btnNewButton_5.setFont(new Font("微软雅黑", Font.PLAIN, 15)); + btnNewButton_5.setBackground(Color.BLUE); + btnNewButton_5.setForeground(Color.BLUE); + btnNewButton_5.setFont(new Font("微软雅黑", Font.PLAIN, 20)); btnNewButton_5.setBounds(356, 103, 73, 24); btnNewButton_5.addActionListener(new ActionListener() { @Override @@ -580,7 +601,7 @@ public class SwingFrame extends JFrame implements ActionListener { startBackupPanel.add(lblNewLabel_19); JButton btnNewButton_6 = new JButton("开始备份"); - btnNewButton_6.setForeground(Color.WHITE); + btnNewButton_6.setForeground(Color.BLUE); btnNewButton_6.setFont(new Font("微软雅黑", Font.PLAIN, 20)); btnNewButton_6.setBackground(new Color(55, 205, 255)); btnNewButton_6.setBounds(606, 98, 113, 35); @@ -630,7 +651,9 @@ public class SwingFrame extends JFrame implements ActionListener { startRestorePanel.add(label); JButton button_5 = new JButton("上传文件:"); - button_5.setFont(new Font("微软雅黑", Font.PLAIN, 15)); + button_5.setBackground(Color.BLUE); + button_5.setForeground(Color.BLUE); + button_5.setFont(new Font("微软雅黑", Font.PLAIN, 20)); button_5.setBounds(14, 97, 120, 24); button_5.addActionListener(new ActionListener() { @Override @@ -675,7 +698,7 @@ public class SwingFrame extends JFrame implements ActionListener { startRestorePanel.add(label_2); JButton button_6 = new JButton("开始还原"); - button_6.setForeground(Color.WHITE); + button_6.setForeground(Color.blue); button_6.setFont(new Font("微软雅黑", Font.PLAIN, 20)); button_6.setBackground(new Color(55, 205, 255)); button_6.setBounds(594, 90, 113, 35);