Browse Source

javaswing系统工具增加测试按钮样式

master
lixl1 3 years ago
parent
commit
fba696834a
  1. BIN
      pictureIcon/Rectanglex 2.png
  2. BIN
      pictureIcon/shujukubeifen.png
  3. BIN
      pictureIcon/syq-unselect.png
  4. BIN
      pictureIcon/youhua2.png
  5. 58
      src/main/java/com/insigma/ui/SwingFrame.java

BIN
pictureIcon/Rectanglex 2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

BIN
pictureIcon/shujukubeifen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
pictureIcon/syq-unselect.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
pictureIcon/youhua2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

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

@ -1,25 +1,21 @@
package com.insigma.ui; package com.insigma.ui;
import com.insigma.service.Computer; import com.insigma.service.Computer;
import com.insigma.service.Database; import com.insigma.service.Database;
import com.insigma.service.Middleware; import com.insigma.service.Middleware;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.awt.EventQueue; import java.awt.EventQueue;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JButton; import javax.swing.JButton;
import java.awt.Panel; import java.awt.Panel;
import java.awt.Toolkit; import java.awt.Toolkit;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;
import java.awt.Font; import java.awt.Font;
import javax.swing.JTextField; import javax.swing.JTextField;
@ -37,6 +33,8 @@ import javax.swing.JCheckBox;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JProgressBar; import javax.swing.JProgressBar;
import javax.swing.JTextPane; import javax.swing.JTextPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileFilter;
import java.awt.Component; import java.awt.Component;
@ -44,7 +42,7 @@ import java.awt.Component;
* @author BeiJing-GWY * @author BeiJing-GWY
*/ */
@Slf4j @Slf4j
public class SwingFrame extends JFrame implements ActionListener { public class SwingFrame extends JFrame implements ActionListener, ChangeListener {
// 计算机 // 计算机
private static Computer computer; private static Computer computer;
@ -129,7 +127,11 @@ public class SwingFrame extends JFrame implements ActionListener {
repairPanel = new JPanel();//系统优化面板 repairPanel = new JPanel();//系统优化面板
repairPanel.setForeground(Color.WHITE); repairPanel.setForeground(Color.WHITE);
repairPanel.setBackground(Color.WHITE); repairPanel.setBackground(Color.WHITE);
tabbedPane.addTab("系统优化", null, repairPanel, null); tabbedPane.addTab("系统优化", new ImageIcon("pictureIcon/youhua2.png"), repairPanel, "repairPanel");
tabbedPane.setEnabledAt(0, true);
tabbedPane.setFont(new Font("微软雅黑", Font.PLAIN, 22));
tabbedPane.setForegroundAt(0, new Color(30, 144, 255));
tabbedPane.addChangeListener(this);
repairPanel.setLayout(null); repairPanel.setLayout(null);
JLabel label_5 = new JLabel("系统优化"); JLabel label_5 = new JLabel("系统优化");
@ -212,12 +214,15 @@ public class SwingFrame extends JFrame implements ActionListener {
repairPanel.add(label_13); repairPanel.add(label_13);
JPanel memoryPanel = new JPanel();//调整内存面板 JPanel memoryPanel = new JPanel();//调整内存
memoryPanel.setBorder(UIManager.getBorder("Button.border")); memoryPanel.setBorder(UIManager.getBorder("Button.border"));
memoryPanel.setAlignmentX(Component.LEFT_ALIGNMENT); memoryPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
memoryPanel.setForeground(Color.WHITE); memoryPanel.setForeground(Color.WHITE);
memoryPanel.setBackground(Color.WHITE); memoryPanel.setBackground(Color.WHITE);
tabbedPane.addTab("调整内存", null, memoryPanel, null); tabbedPane.addTab("调整内存", new ImageIcon("pictureIcon/Rectanglex 2.png"), memoryPanel, "memoryPanel");
tabbedPane.setEnabledAt(0, true);
tabbedPane.setFont(new Font("微软雅黑", Font.PLAIN, 22));
tabbedPane.addChangeListener(this);
memoryPanel.setLayout(null); memoryPanel.setLayout(null);
JLabel lblNewLabel = new JLabel("调整内存"); JLabel lblNewLabel = new JLabel("调整内存");
@ -314,7 +319,10 @@ public class SwingFrame extends JFrame implements ActionListener {
backupsPanel = new JPanel();//数据库备份、还原面板 backupsPanel = new JPanel();//数据库备份、还原面板
backupsPanel.setBackground(Color.WHITE); backupsPanel.setBackground(Color.WHITE);
tabbedPane.addTab("数据库备份", null, backupsPanel, null); tabbedPane.addTab("数据库份", new ImageIcon("pictureIcon/shujukubeifen.png"), backupsPanel, "backupsPanel");
tabbedPane.setEnabledAt(0, true);
tabbedPane.setFont(new Font("微软雅黑", Font.PLAIN, 22));
tabbedPane.addChangeListener(this);
backupsPanel.setLayout(null); backupsPanel.setLayout(null);
JLabel lblNewLabel_12 = new JLabel("数据库备份"); JLabel lblNewLabel_12 = new JLabel("数据库备份");
@ -406,7 +414,10 @@ public class SwingFrame extends JFrame implements ActionListener {
Panel upgradePanel = new Panel();//系统升级面板 Panel upgradePanel = new Panel();//系统升级面板
upgradePanel.setBackground(Color.WHITE); upgradePanel.setBackground(Color.WHITE);
tabbedPane.addTab("系统升级", null, upgradePanel, null); tabbedPane.addTab("系统升级", new ImageIcon("pictureIcon/syq-unselect.png"), upgradePanel, "upgradePanel");
tabbedPane.setEnabledAt(0, true);
tabbedPane.setFont(new Font("微软雅黑", Font.PLAIN, 22));
tabbedPane.addChangeListener(this);
upgradePanel.setLayout(null); upgradePanel.setLayout(null);
JLabel lblNewLabel_8 = new JLabel("<html><b>安装包/升级包下载</b><html>"); JLabel lblNewLabel_8 = new JLabel("<html><b>安装包/升级包下载</b><html>");
@ -754,4 +765,31 @@ public class SwingFrame extends JFrame implements ActionListener {
} }
} }
} }
@Override
public void stateChanged(ChangeEvent e) {
JTabbedPane pane = (JTabbedPane) e.getSource();
int selectedIndex = pane.getSelectedIndex();
if(selectedIndex == 0) {
tabbedPane.setForegroundAt(0, new Color(30, 144, 255));
tabbedPane.setForegroundAt(1, Color.black);
tabbedPane.setForegroundAt(2, Color.black);
tabbedPane.setForegroundAt(3, Color.black);
}else if(selectedIndex == 1) {
tabbedPane.setForegroundAt(1, new Color(30, 144, 255));
tabbedPane.setForegroundAt(0, Color.black);
tabbedPane.setForegroundAt(2, Color.black);
tabbedPane.setForegroundAt(3, Color.black);
}else if(selectedIndex == 2) {
tabbedPane.setForegroundAt(2, new Color(30, 144, 255));
tabbedPane.setForegroundAt(1, Color.black);
tabbedPane.setForegroundAt(0, Color.black);
tabbedPane.setForegroundAt(3, Color.black);
}else if(selectedIndex == 3) {
tabbedPane.setForegroundAt(3, new Color(30, 144, 255));
tabbedPane.setForegroundAt(1, Color.black);
tabbedPane.setForegroundAt(2, Color.black);
tabbedPane.setForegroundAt(0, Color.black);
}
}
} }
Loading…
Cancel
Save