| | |
| | | |
| | | headerPanel.add(nameLabel, BorderLayout.WEST); |
| | | |
| | | // 右侧区域:状态文字 + 按钮 |
| | | JPanel rightPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0)); |
| | | rightPanel.setBackground(CARD_BACKGROUND); |
| | | rightPanel.setOpaque(false); |
| | | |
| | | // 状态文字标签(根据是否选中显示/隐藏) |
| | | JLabel statusLabel = new JLabel("已设置为当前地块"); |
| | | statusLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13)); |
| | | statusLabel.setForeground(PRIMARY_COLOR); |
| | | boolean isCurrent = dikuai.getLandNumber() != null && dikuai.getLandNumber().equals(currentWorkLandNumber); |
| | | statusLabel.setVisible(isCurrent); |
| | | |
| | | JButton workToggleBtn = createWorkToggleButton(dikuai); |
| | | headerPanel.add(workToggleBtn, BorderLayout.EAST); |
| | | |
| | | // 将状态标签和按钮关联,以便在按钮状态变化时更新标签 |
| | | workToggleBtn.putClientProperty("statusLabel", statusLabel); |
| | | |
| | | rightPanel.add(statusLabel); |
| | | rightPanel.add(workToggleBtn); |
| | | |
| | | headerPanel.add(rightPanel, BorderLayout.EAST); |
| | | |
| | | card.add(headerPanel, BorderLayout.NORTH); |
| | | |
| | |
| | | button.setText(isCurrent ? "当前地块" : "设为当前"); |
| | | } |
| | | button.setToolTipText(isCurrent ? "取消当前作业地块" : "设为当前作业地块"); |
| | | |
| | | // 更新状态文字标签的显示/隐藏 |
| | | Object statusLabelObj = button.getClientProperty("statusLabel"); |
| | | if (statusLabelObj instanceof JLabel) { |
| | | JLabel statusLabel = (JLabel) statusLabelObj; |
| | | statusLabel.setVisible(isCurrent); |
| | | } |
| | | } |
| | | |
| | | private void ensureWorkIconsLoaded() { |