| | |
| | | private final MenuItemListener menuItemListener; |
| | | |
| | | public ConfigSet(JFrame parent) { |
| | | super(parent, "设置", true); |
| | | super(parent, "", true); |
| | | configManager = Chushihua.getInstance(); |
| | | menuItemListener = new MenuItemListener(); |
| | | // 记录进入设置页面前的轮询状态 |
| | |
| | | mainPanel.add(createHeaderPanel(), BorderLayout.NORTH); |
| | | mainPanel.add(createMenuGridPanel(), BorderLayout.CENTER); |
| | | |
| | | // 添加版权信息在底部 |
| | | mainPanel.add(createCopyrightPanel(), BorderLayout.SOUTH); |
| | | |
| | | getContentPane().add(mainPanel); |
| | | } |
| | | |
| | | // 创建版权信息面板 |
| | | private JPanel createCopyrightPanel() { |
| | | JPanel copyrightPanel = new JPanel(); |
| | | copyrightPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); |
| | | copyrightPanel.setOpaque(true); |
| | | copyrightPanel.setBackground(DARK_COLOR); |
| | | copyrightPanel.setBorder(new EmptyBorder(10, 0, 5, 0)); |
| | | |
| | | JLabel copyrightLabel = new JLabel("北京华星北斗智控技术有限公司 版权所有 2025"); |
| | | copyrightLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12)); |
| | | copyrightLabel.setForeground(new Color(160, 160, 160)); |
| | | |
| | | copyrightPanel.add(copyrightLabel); |
| | | return copyrightPanel; |
| | | } |
| | | |
| | | private JPanel createHeaderPanel() { |
| | |
| | | closeButton.setOpaque(true); // 确保不透明 |
| | | closeButton.setFocusPainted(false); |
| | | closeButton.setBorder(BorderFactory.createEmptyBorder(10, 18, 10, 18)); |
| | | closeButton.setIcon(getCachedIcon("✕", 16)); |
| | | closeButton.addActionListener(e -> dispose()); |
| | | closeButton.addActionListener(e -> { |
| | | // 强制开启轮询查询功能 |
| | | forceStartPolling(); |
| | | dispose(); |
| | | }); |
| | | |
| | | // 添加悬停效果 |
| | | closeButton.addMouseListener(new java.awt.event.MouseAdapter() { |
| | |
| | | return icon; |
| | | } |
| | | |
| | | private void showSystemDebugDialog() { |
| | | SystemDebugDialog.showSystemDebugDialog((JFrame) getParent()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void dispose() { |
| | | // 退出设置页面时恢复轮询控制 |
| | | SystemDebugDialog.setPollingControlEnabled(true); |
| | | |
| | | // 退出设置页面时恢复轮询 |
| | | resumePollingWhenExiting(); |
| | | |
| | |
| | | configDialog.setVisible(true); |
| | | }); |
| | | } |
| | | /** |
| | | * 强制开启轮询查询功能(无论当前状态如何) |
| | | */ |
| | | private void forceStartPolling() { |
| | | try { |
| | | // 如果轮询未运行,则启动轮询 |
| | | if (!lunxun.isPolling()) { |
| | | boolean started = lunxun.startPolling(); |
| | | if (started) { |
| | | //System.out.println("强制开启:轮询查询已启动"); |
| | | } else { |
| | | System.err.println("强制开启:启动轮询查询失败"); |
| | | } |
| | | } |
| | | // 如果轮询已运行但处于暂停状态,则恢复轮询 |
| | | else if (lunxun.isPaused()) { |
| | | boolean resumed = lunxun.resumePolling(); |
| | | if (resumed) { |
| | | //System.out.println("强制开启:轮询查询已恢复"); |
| | | } else { |
| | | System.err.println("强制开启:恢复轮询查询失败"); |
| | | } |
| | | } |
| | | // 如果轮询已运行且未暂停,则无需操作 |
| | | else { |
| | | //System.out.println("强制开启:轮询查询已在运行中"); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | System.err.println("强制开启轮询查询时发生异常: " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | // 在 showSystemDebugDialog 方法中添加 |
| | | private void showSystemDebugDialog() { |
| | | // 在打开调试对话框时禁用轮询控制 |
| | | SystemDebugDialog.setPollingControlEnabled(false); |
| | | SystemDebugDialog.showSystemDebugDialog((JFrame) getParent()); |
| | | } |
| | | } |