| | |
| | | package set; |
| | | |
| | | import chuankou.SerialPortNativeLoader; |
| | | import chuankou.SerialPortPreferences; |
| | | import chuankou.SerialPortService; |
| | | import chuankou.sendmessage; |
| | | import publicway.buttonset; |
| | | |
| | | import com.fazecast.jSerialComm.SerialPort; |
| | | import ui.UIConfig; |
| | | import javax.swing.*; |
| | |
| | | private final SerialPortService serialService = sendmessage.getActiveService(); |
| | | private final JComboBox<String> portComboBox = new JComboBox<>(); |
| | | private final JComboBox<Integer> baudComboBox = new JComboBox<>(new Integer[]{115200, 921600, 57600}); |
| | | private final JButton connectButton = new JButton("连接"); |
| | | private final JButton pauseButton = new JButton("暂停显示"); |
| | | private final JButton closeButton = new JButton("关闭"); |
| | | private final JButton clearButton = new JButton("清空日志"); |
| | | private JButton connectButton; |
| | | private JButton pauseButton; |
| | | private JButton closeButton; |
| | | private JButton clearButton; |
| | | private final JCheckBox hexDisplayCheckBox = new JCheckBox("HEX显示"); |
| | | private final JCheckBox autoConnectCheckBox = new JCheckBox("启动时连接"); |
| | | private final JLabel statusLabel = new JLabel("未连接"); |
| | |
| | | public debug(Window owner, Color themeColor) { |
| | | super(owner, "系统调试", ModalityType.APPLICATION_MODAL); |
| | | this.themeColor = themeColor != null ? themeColor : new Color(52, 152, 219); |
| | | |
| | | // 确保库已加载 |
| | | try { |
| | | SerialPortNativeLoader.ensureLibraryPresent(); |
| | | } catch (Exception e) { |
| | | JOptionPane.showMessageDialog(owner, |
| | | "串口库初始化失败: " + e.getMessage(), |
| | | "错误", JOptionPane.ERROR_MESSAGE); |
| | | } |
| | | |
| | | this.connectButton = buttonset.createStyledButton("连接", this.themeColor); |
| | | this.pauseButton = buttonset.createStyledButton("暂停显示", new Color(120, 120, 120)); |
| | | this.closeButton = buttonset.createStyledButton("关闭", new Color(240, 240, 240)); |
| | | this.clearButton = buttonset.createStyledButton("清空日志", this.themeColor); |
| | | initializeUI(); |
| | | loadPreferences(); |
| | | refreshSerialPorts(); |
| | |
| | | pauseButton.setFont(pauseButton.getFont().deriveFont(Font.PLAIN, 13f)); |
| | | pauseButton.setPreferredSize(new Dimension(100, 32)); |
| | | pauseButton.setFocusPainted(false); |
| | | pauseButton.setBackground(new Color(120, 120, 120)); |
| | | pauseButton.setForeground(Color.WHITE); |
| | | pauseButton.addActionListener(e -> togglePause()); |
| | | |
| | | clearButton.setFont(clearButton.getFont().deriveFont(Font.PLAIN, 13f)); |