| | |
| | | import javax.swing.*; |
| | | |
| | | import gecaoji.Device; |
| | | import publicway.buttonset; |
| | | |
| | | import java.awt.*; |
| | | import java.awt.event.ActionListener; |
| | |
| | | titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 14)); |
| | | titleLabel.setForeground(Color.DARK_GRAY); |
| | | |
| | | JButton actionButton = createInlineButton(buttonText, buttonColor); |
| | | JButton actionButton = buttonset.createStyledButton(buttonText, buttonColor); |
| | | actionButton.addActionListener(actionListener); |
| | | |
| | | panel.add(titleLabel); |
| | |
| | | |
| | | return panel; |
| | | } |
| | | |
| | | private JButton createInlineButton(String text, Color bgColor) { |
| | | JButton button = new JButton(text); |
| | | button.setFont(new Font("微软雅黑", Font.BOLD, 14)); |
| | | button.setBackground(bgColor); |
| | | button.setForeground(Color.WHITE); |
| | | button.setFocusPainted(false); |
| | | button.setBorder(BorderFactory.createEmptyBorder(8, 18, 8, 18)); |
| | | Dimension size = new Dimension(90, 36); |
| | | button.setPreferredSize(size); |
| | | button.setMinimumSize(size); |
| | | button.setMaximumSize(size); |
| | | |
| | | button.addMouseListener(new java.awt.event.MouseAdapter() { |
| | | public void mouseEntered(java.awt.event.MouseEvent evt) { |
| | | button.setBackground(brightenColor(bgColor)); |
| | | } |
| | | public void mouseExited(java.awt.event.MouseEvent evt) { |
| | | button.setBackground(bgColor); |
| | | } |
| | | }); |
| | | |
| | | return button; |
| | | } |
| | | |
| | | private Color brightenColor(Color color) { |
| | | int r = Math.min(255, color.getRed() + 30); |