List of usage examples for javax.swing UIManager getColor
public static Color getColor(Object key)
From source file:Main.java
public static void main(String[] args) throws Exception { String[] items = new String[] { "", "Apple", "Banana", "Carrot" }; Color bgColor = UIManager.getColor("TextField.background"); UIManager.put("ComboBox.selectionBackground", new ColorUIResource(bgColor)); JComboBox<String> combo1 = new JComboBox<>(items); combo1.setPrototypeDisplayValue("XXXXXXXXXXXXXXX"); combo1.setEditable(true);//from ww w . j a v a 2 s. c o m combo1.setSelectedIndex(-1); JComboBox<String> combo2 = new JComboBox<>(items); combo2.setPrototypeDisplayValue("XXXXXXXXXXXXXXX"); combo2.setEditable(false); combo2.setSelectedIndex(-1); combo2.setBackground(bgColor); JFrame frame = new JFrame(); Container c = frame.getContentPane(); c.setLayout(new FlowLayout()); c.add(combo1); c.add(combo2); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 100); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:TextAcceleratorExample.java
public static void main(String[] args) { try {// ww w. ja v a 2 s.co m UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JLabel l; JTextField t; JButton b; JFrame f = new JFrame("Text Accelerator Example"); Container cp = f.getContentPane(); cp.setLayout(new GridBagLayout()); cp.setBackground(UIManager.getColor("control")); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = GridBagConstraints.RELATIVE; c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(2, 2, 2, 2); c.anchor = GridBagConstraints.EAST; cp.add(l = new JLabel("Name:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('n'); cp.add(l = new JLabel("House/Street:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('h'); cp.add(l = new JLabel("City:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('c'); cp.add(l = new JLabel("State/County:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('s'); cp.add(l = new JLabel("Zip/Post code:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('z'); cp.add(l = new JLabel("Telephone:", SwingConstants.RIGHT), c); l.setDisplayedMnemonic('t'); cp.add(b = new JButton("Clear"), c); b.setMnemonic('l'); c.gridx = 1; c.gridy = 0; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; cp.add(t = new JTextField(35), c); t.setFocusAccelerator('n'); c.gridx = 1; c.gridy = GridBagConstraints.RELATIVE; cp.add(t = new JTextField(35), c); t.setFocusAccelerator('h'); cp.add(t = new JTextField(35), c); t.setFocusAccelerator('c'); cp.add(t = new JTextField(35), c); t.setFocusAccelerator('s'); cp.add(t = new JTextField(35), c); t.setFocusAccelerator('z'); cp.add(t = new JTextField(35), c); t.setFocusAccelerator('t'); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; cp.add(b = new JButton("OK"), c); b.setMnemonic('o'); f.pack(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); f.setVisible(true); }
From source file:Main.java
public static Color getBackgroundColor() { if (backgroundColor != null) { return backgroundColor; }/* w ww. j av a 2s.c o m*/ backgroundColor = UIManager.getColor("Table.background"); if (backgroundColor == null) { backgroundColor = new JList().getBackground(); } //sometimes the UIManager color won't work backgroundColor = new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue()); return backgroundColor; }
From source file:Main.java
public static Color getForegroundColor() { if (foregroundColor != null) { return foregroundColor; }/*www .j av a2 s . c o m*/ foregroundColor = UIManager.getColor("Table.foreground"); if (foregroundColor == null) { foregroundColor = new JList().getForeground(); } //sometimes the UIManager color won't work foregroundColor = new Color(foregroundColor.getRed(), foregroundColor.getGreen(), foregroundColor.getBlue()); //sometimes the UIManager color won't work return foregroundColor; }
From source file:Main.java
/** * Get the foreground color for the current UI. * @return The desired foreground color. *///from w w w . j a va 2s .co m public static Color getSelectionForegroundColor() { if (selectionForegroundColor != null) { return selectionForegroundColor; } //for windows selectionForegroundColor = (Color) Toolkit.getDefaultToolkit() .getDesktopProperty("win.item.highlightTextColor"); if (selectionForegroundColor == null) { selectionForegroundColor = UIManager.getColor("Table.selectionForeground"); if (selectionForegroundColor == null) { selectionForegroundColor = UIManager.getColor("Table[Enabled+Selected].textForeground"); if (selectionForegroundColor == null) { selectionForegroundColor = new JList().getSelectionForeground(); } } //sometimes the UIManager color won't work selectionForegroundColor = new Color(selectionForegroundColor.getRed(), selectionForegroundColor.getGreen(), selectionForegroundColor.getBlue()); } return selectionForegroundColor; }
From source file:Main.java
public static Color getTableHeaderColor() { return UIManager.getColor("TableHeader.background"); }
From source file:Main.java
public static Color getTableBackgroundColor(boolean colored) { if (colored)/*ww w . ja v a 2 s . c o m*/ return new Color(0xf4f4f4); return UIManager.getColor("Table.background"); }
From source file:PaintUtils.java
/** @return the color used to indicate when a component has * focus. By default this uses the color (64,113,167), but you can * override this by calling://from w w w. ja va 2 s .co m * <BR><code>UIManager.put("focusRing",customColor);</code> */ public static Color getFocusRingColor() { Object obj = UIManager.getColor("focusRing"); if (obj instanceof Color) return (Color) obj; return new Color(64, 113, 167); }
From source file:de.aidger.view.utils.Charts.java
/** * Creates a 3D pie chart./*from ww w . j a va 2s.co m*/ * * @param title * the diagram title * @param dataset * the dataset. * @param width * the width of the chart as image * @param height * the height of the chart as image * * @return the 3D pie chart as image */ public static ImageIcon createPieChart3D(String title, PieDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false); Font titleFont = UIManager.getFont("TitledBorder.font"); chart.setBackgroundPaint(null); chart.getLegend().setBackgroundPaint(null); chart.getTitle().setFont(new Font(titleFont.getName(), titleFont.getStyle(), 14)); chart.getTitle().setPaint(UIManager.getColor("TitledBorder.titleColor")); chart.setBorderPaint(null); chart.getLegend().setBorder(0, 0, 0, 0); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setForegroundAlpha(0.9f); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage(_("No data to display.")); plot.setLabelGenerator(null); plot.setInsets(new RectangleInsets(10, 1, 5, 1)); plot.setBackgroundPaint(null); plot.setOutlineVisible(false); plot.setDarkerSides(true); return new ImageIcon(chart.createBufferedImage(width, height)); }
From source file:Main.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { setBackground(UIManager.getColor("Table.selectionBackground")); }//from www . ja v a2 s . c o m if (hasFocus) { setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); if (table.isCellEditable(row, column)) { super.setForeground(UIManager.getColor("Table.focusCellForeground")); super.setBackground(UIManager.getColor("Table.focusCellBackground")); } } else { setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); } setText((String) (value)); table.setRowHeight(row, getPreferredSize().height + row * 10); return this; }