public void actionPerformed(ActionEvent e) { if (e.getSource() == colorBorderButton) { Color chosenColor = JColorChooser.showDialog( colorBorderButton, messageBundle.getString("viewer.utilityPane.annotation.ink.colorBorderChooserTitle"), colorBorderButton.getBackground()); if (chosenColor != null) { // change the colour of the button background colorBorderButton.setBackground(chosenColor); annotation.setColor(chosenColor); // save the action state back to the document structure. updateCurrentAnnotation(); currentAnnotationComponent.resetAppearanceShapes(); currentAnnotationComponent.repaint(); } } }
/** * Method used to highlight or low-light a space on the board. This is used to indicate which * space was clicked on, or which spaces a piece can move to * * @param space Space on the board to be modified * @param highlight If true, brighten space, else, darken space */ public void light(JButton space, boolean highlight) { // set the space to be clickable space.setEnabled(true); Color color = space.getBackground(); int red = color.getRed(); int green = color.getGreen(); int blue = color.getBlue(); int[] components = {red, green, blue}; for (int i = 0; i < 3; i++) { // modify the rgb values if (highlight) { components[i] += HIGHLIGHT_FACTOR; } else { components[i] -= LOWLIGHT_FACTOR; } if (components[i] > 255) { components[i] = 255; } else if (components[i] < 0) { components[i] = 0; } } space.setBackground(new Color(components[0], components[1], components[2])); }
@Override public Object getItem() { return editor_.getBackground(); }
public void actionPerformed(ActionEvent evt) { JButton button = (JButton) evt.getSource(); getColorSelectionModel().setSelectedColor(button.getBackground()); }