17491 15 часов назад
Родитель
Сommit
6ae666a5a5
1 измененных файлов с 32 добавлено и 28 удалено
  1. 32 28
      src/com/mes/ui/MesClient.java

+ 32 - 28
src/com/mes/ui/MesClient.java

@@ -857,6 +857,8 @@ public class MesClient extends JFrame {
         // 自适应屏幕分辨率,避免工控机出现滚动条
         setExtendedState(JFrame.MAXIMIZED_BOTH);
         // setBounds(0, 0, 1024, 768);
+        final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+        final boolean compactLayout = screenSize.width <= 1280 || screenSize.height <= 800;
 
         JMenuBar menuBar = new JMenuBar();
         menuBar.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 26));
@@ -983,7 +985,7 @@ public class MesClient extends JFrame {
 
         tabbedPane = new JTabbedPane(JTabbedPane.TOP);
         tabbedPane.setMinimumSize(new Dimension(400, 50));
-        tabbedPane.setFont(new Font("宋体", Font.BOLD, 22));
+        tabbedPane.setFont(new Font("宋体", Font.BOLD, compactLayout ? 16 : 22));
         contentPane.add(tabbedPane);
 
         //首页 - 使用BorderLayout布局
@@ -994,15 +996,16 @@ public class MesClient extends JFrame {
         // 顶部容器
         JPanel topContainer = new JPanel();
         topContainer.setLayout(new BoxLayout(topContainer, BoxLayout.Y_AXIS));
-        topContainer.setBorder(new EmptyBorder(20, 20, 10, 20));
+        topContainer.setBorder(new EmptyBorder(compactLayout ? 6 : 20, compactLayout ? 8 : 20,
+                compactLayout ? 3 : 10, compactLayout ? 8 : 20));
 
         // 扫码区域
-        JPanel scanRow = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
+        JPanel scanRow = new JPanel(new FlowLayout(FlowLayout.CENTER, compactLayout ? 6 : 10, compactLayout ? 4 : 10));
         product_sn = new JTextField(30);
         product_sn.setHorizontalAlignment(SwingConstants.CENTER);
         product_sn.setEditable(true);
-        product_sn.setFont(new Font("微软雅黑", Font.PLAIN, 28));
-        product_sn.setPreferredSize(new Dimension(600, 70));
+        product_sn.setFont(new Font("微软雅黑", Font.PLAIN, compactLayout ? 22 : 28));
+        product_sn.setPreferredSize(new Dimension(compactLayout ? 500 : 600, compactLayout ? 48 : 70));
         product_sn.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 scan_type = 1;
@@ -1018,37 +1021,37 @@ public class MesClient extends JFrame {
                 scanBarcode();
             }
         });
-        f_scan_data_bt_1.setFont(new Font("微软雅黑", Font.PLAIN, 32));
-        f_scan_data_bt_1.setPreferredSize(new Dimension(198, 70));
+        f_scan_data_bt_1.setFont(new Font("微软雅黑", Font.PLAIN, compactLayout ? 24 : 32));
+        f_scan_data_bt_1.setPreferredSize(new Dimension(compactLayout ? 150 : 198, compactLayout ? 48 : 70));
         scanRow.add(f_scan_data_bt_1);
 
         topContainer.add(scanRow);
 
         // 测试参数显示区域
-        JPanel paramRow = new JPanel(new FlowLayout(FlowLayout.CENTER, 30, 10));
+        JPanel paramRow = new JPanel(new FlowLayout(FlowLayout.CENTER, compactLayout ? 12 : 30, compactLayout ? 3 : 10));
 
         JLabel lblNewLabel = new JLabel("测试压:");
-        lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
+        lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, compactLayout ? 16 : 20));
         paramRow.add(lblNewLabel);
 
         param1 = new JTextField(12);
         param1.setEditable(false);
-        param1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+        param1.setFont(new Font("微软雅黑", Font.PLAIN, compactLayout ? 15 : 18));
         paramRow.add(param1);
 
         JLabel lblNewLabel_1 = new JLabel("泄露值:");
-        lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
+        lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, compactLayout ? 16 : 20));
         paramRow.add(lblNewLabel_1);
 
         param2 = new JTextField(12);
         param2.setEditable(false);
-        param2.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+        param2.setFont(new Font("微软雅黑", Font.PLAIN, compactLayout ? 15 : 18));
         paramRow.add(param2);
 
         topContainer.add(paramRow);
 
         // 结果显示区域
-        JPanel resultRow = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
+        JPanel resultRow = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, compactLayout ? 3 : 10));
         result = new JLabel("等待结果") {
             @Override
             protected void paintComponent(Graphics g) {
@@ -1064,14 +1067,14 @@ public class MesClient extends JFrame {
         };
         result.setForeground(Color.GRAY);
         result.setHorizontalAlignment(SwingConstants.CENTER);
-        result.setFont(new Font("微软雅黑", Font.BOLD, 50));
-        result.setPreferredSize(new Dimension(356, 89));
+        result.setFont(new Font("微软雅黑", Font.BOLD, compactLayout ? 34 : 50));
+        result.setPreferredSize(new Dimension(compactLayout ? 280 : 356, compactLayout ? 58 : 89));
         resultRow.add(result);
 
         topContainer.add(resultRow);
 
         // 倒计时标签
-        JPanel countdownRow = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 5));
+        JPanel countdownRow = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, compactLayout ? 1 : 5));
         countdownLabel = new JLabel("");
         countdownLabel.setFont(new Font("微软雅黑", Font.BOLD, 20));
         countdownLabel.setForeground(new Color(255, 140, 0));
@@ -1082,12 +1085,12 @@ public class MesClient extends JFrame {
         topContainer.add(countdownRow);
 
         // 人工判定NG按钮
-        JPanel manualNgRow = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 5));
+        JPanel manualNgRow = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, compactLayout ? 1 : 5));
         manual_ng_bt = new JButton("人工判定NG");
         manual_ng_bt.setFont(new Font("微软雅黑", Font.BOLD, 18));
         manual_ng_bt.setForeground(Color.WHITE);
         manual_ng_bt.setBackground(new Color(255, 140, 0));
-        manual_ng_bt.setPreferredSize(new Dimension(200, 50));
+        manual_ng_bt.setPreferredSize(new Dimension(compactLayout ? 170 : 200, compactLayout ? 38 : 50));
         manual_ng_bt.setVisible(false); // 初始隐藏
         manual_ng_bt.addActionListener(new ActionListener() {
             @Override
@@ -1103,10 +1106,11 @@ public class MesClient extends JFrame {
         // 中间面板:漏点按钮
         JPanel centerPanel = new JPanel();
         centerPanel.setLayout(new BorderLayout(10, 10));
-        centerPanel.setBorder(new EmptyBorder(10, 20, 10, 20));
+        centerPanel.setBorder(new EmptyBorder(compactLayout ? 4 : 10, compactLayout ? 8 : 20,
+                compactLayout ? 4 : 10, compactLayout ? 8 : 20));
 
         JPanel weldPanel = new JPanel();
-        weldPanel.setLayout(new GridLayout(5, 8, 10, 10));
+        weldPanel.setLayout(new GridLayout(5, 8, compactLayout ? 4 : 10, compactLayout ? 4 : 10));
         weldPanel.setOpaque(false);
         addWeldButtonsToPanel(weldPanel, 0, weldButtons.length);
         centerPanel.add(weldPanel, BorderLayout.CENTER);
@@ -1115,8 +1119,8 @@ public class MesClient extends JFrame {
 
         // 底部面板:OK/NG按钮
         JPanel bottomPanel = new JPanel();
-        bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 10));
-        bottomPanel.setBorder(new EmptyBorder(10, 10, 20, 10));
+        bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER, compactLayout ? 8 : 20, compactLayout ? 4 : 10));
+        bottomPanel.setBorder(new EmptyBorder(compactLayout ? 4 : 10, 10, compactLayout ? 6 : 20, 10));
 
         finish_ok_bt = new JButton("OK");
         finish_ok_bt.setEnabled(false);
@@ -1126,8 +1130,8 @@ public class MesClient extends JFrame {
             }
         });
         finish_ok_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ok_bg.png")));
-        finish_ok_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
-        finish_ok_bt.setPreferredSize(new Dimension(240, 80));
+        finish_ok_bt.setFont(new Font("微软雅黑", Font.PLAIN, compactLayout ? 24 : 32));
+        finish_ok_bt.setPreferredSize(new Dimension(compactLayout ? 180 : 240, compactLayout ? 56 : 80));
         bottomPanel.add(finish_ok_bt);
 
         finish_ng_bt = new JButton("NG");
@@ -1138,8 +1142,8 @@ public class MesClient extends JFrame {
             }
         });
         finish_ng_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ng_bg.png")));
-        finish_ng_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
-        finish_ng_bt.setPreferredSize(new Dimension(240, 80));
+        finish_ng_bt.setFont(new Font("微软雅黑", Font.PLAIN, compactLayout ? 24 : 32));
+        finish_ng_bt.setPreferredSize(new Dimension(compactLayout ? 180 : 240, compactLayout ? 56 : 80));
         bottomPanel.add(finish_ng_bt);
 
         finish_ng_without_leak_bt = new JButton("无漏点NG");
@@ -1150,8 +1154,8 @@ public class MesClient extends JFrame {
             }
         });
         finish_ng_without_leak_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ng_bg.png")));
-        finish_ng_without_leak_bt.setFont(new Font("微软雅黑", Font.PLAIN, 24));
-        finish_ng_without_leak_bt.setPreferredSize(new Dimension(240, 80));
+        finish_ng_without_leak_bt.setFont(new Font("微软雅黑", Font.PLAIN, compactLayout ? 18 : 24));
+        finish_ng_without_leak_bt.setPreferredSize(new Dimension(compactLayout ? 180 : 240, compactLayout ? 56 : 80));
         bottomPanel.add(finish_ng_without_leak_bt);
 
         indexPanelA.add(bottomPanel, BorderLayout.SOUTH);