| | |
| | | cardSlotsPanel.removeAll(); |
| | | slotButtons.clear(); |
| | | |
| | | int updatedSlots = 0; |
| | | int errorSlots = 0; |
| | | |
| | | for (int i = 1; i <= TOTAL_SLOTS; i++) { |
| | | final int slotId = i; |
| | | SlotStatus status = getSlotStatusFromManager(slotId); |
| | |
| | | // 添加调试信息 |
| | | Fkj slotInfo = slotManager.getSlotInfo(slotId); |
| | | if (slotInfo != null) { |
| | | updatedSlots++; |
| | | } else { |
| | | System.err.println("卡槽 " + slotId + " - 获取信息失败"); |
| | | errorSlots++; |
| | | } |
| | | |
| | | JButton slotButton = new JButton(String.valueOf(slotId)); |
| | |
| | | cardSlotsPanel.revalidate(); |
| | | cardSlotsPanel.repaint(); |
| | | |
| | | System.out.println("卡槽显示更新完成: " + updatedSlots + " 个成功, " + errorSlots + " 个失败"); |
| | | // System.out.println("卡槽显示更新完成: " + updatedSlots + " 个成功, " + errorSlots + " 个失败"); |
| | | } |
| | | |
| | | private Color brighterColor(Color color) { |
| | |
| | | if (panel.getComponentCount() >= 2) { |
| | | JLabel textLabel = (JLabel) panel.getComponent(1); |
| | | if (textLabel.getText().startsWith("串口:")) { |
| | | String statusText = lunxun.isSerialConnected() ? "正常" : "断开"; |
| | | Color statusColor = lunxun.isSerialConnected() ? |
| | | new Color(52, 152, 219) : new Color(231, 76, 60); |
| | | |
| | |
| | | } |
| | | return "串口解析器未初始化"; |
| | | } |
| | | |
| | | /** |
| | | * 创建美化按钮 |
| | | */ |
| | | private JButton createStyledButton(String text, Color color) { |
| | | JButton button = new JButton(text); |
| | | button.setFont(new Font("Microsoft YaHei", Font.BOLD, 14)); |
| | | button.setBackground(color); |
| | | button.setForeground(Color.WHITE); |
| | | button.setFocusPainted(false); |
| | | button.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); |
| | | button.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
| | | |
| | | // 鼠标悬停效果 |
| | | button.addMouseListener(new java.awt.event.MouseAdapter() { |
| | | public void mouseEntered(java.awt.event.MouseEvent evt) { |
| | | button.setBackground(brighterColor(color)); |
| | | } |
| | | |
| | | public void mouseExited(java.awt.event.MouseEvent evt) { |
| | | button.setBackground(color); |
| | | } |
| | | }); |
| | | |
| | | return button; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 验证取卡密码 |