List of utility methods to do JComponent Color
JTextArea | createTextArea(String str, Color color) create Text Area JTextArea desc = new JTextArea(str); desc.setBackground(color); desc.setEditable(false); desc.setCaretColor(color); desc.setLineWrap(true); desc.setWrapStyleWord(true); return desc; |
AbstractColorChooserPanel | findPanel(JColorChooser chooser, String name) find Panel AbstractColorChooserPanel[] panels = chooser.getChooserPanels(); for (int i = 0; i < panels.length; i++) { String clsName = panels[i].getClass().getName(); if (clsName.equals(name)) { return panels[i]; return null; ... |
void | fixOsxColorChooser(JColorChooser chooser) fix Osx Color Chooser if (!UIManager.getLookAndFeel().getName().equals("Mac OS X")) return; AbstractColorChooserPanel[] panels = chooser.getChooserPanels(); for (JPanel p : panels) { if (p != null) { p.setOpaque(false); ((JComponent) p.getParent()).setOpaque(false); for (Component c : p.getComponents()) { ... |
void | flashMessage(final Window parent, String string, Color background, Color foreground, final long howLong) flash Message final int fontSize = 20; final JLabel label = new JLabel(string); final JDialog dialog = new JDialog(parent); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setModalExclusionType(ModalExclusionType.NO_EXCLUDE); label.setFont(label.getFont().deriveFont(fontSize)); label.setBackground(background); label.setForeground(foreground); ... |
void | highlightForDebugging(JComponent component, Color color) Highlights a given component with a given color. component.setBackground(color); component.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, color)); |
void | installColors(Component c, Color background, Color foreground) install Colors Color bg = c.getBackground(); if ((background != null) && ((bg == null) || ((bg instanceof UIResource)))) { c.setBackground(background); Color fg = c.getForeground(); if ((foreground != null) && ((fg == null) || ((fg instanceof UIResource)))) c.setForeground(foreground); |
ImageIcon | makeEmptyIcon(Dimension size, Color color) make Empty Icon ImageIcon result = null; BufferedImage bufferedImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB); Graphics graphics = bufferedImage.getGraphics(); graphics.setColor(color); graphics.fillRect(0, 0, size.width, size.height); result = new ImageIcon(bufferedImage); return result; |
JComponent | newColorComponent(Color value) new Color Component JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); final JPanel label = new JPanel(); label.setPreferredSize(new Dimension(16, 16)); label.setBackground(value); buttonPanel.add(label); return buttonPanel; |
float | normalize(float q, float p, float color) This method was copied from class javax.swing.colorchooser.ColorModelHSL of Java 7. if (color < 1.0f) { return p + (q - p) * color; if (color < 3.0f) { return q; if (color < 4.0f) { return p + (q - p) * (4.0f - color); ... |
void | recursiveSetBackground(Component comp, Color color) recursive Set Background if (comp instanceof JToolBar || comp instanceof JButton) return; comp.setBackground(color); if (comp instanceof Container) { Container cc = (Container) comp; for (int i = 0; i < cc.getComponentCount(); i++) recursiveSetBackground(cc.getComponent(i), color); |