Example usage for javax.swing.plaf ColorUIResource ColorUIResource

List of usage examples for javax.swing.plaf ColorUIResource ColorUIResource

Introduction

In this page you can find the example usage for javax.swing.plaf ColorUIResource ColorUIResource.

Prototype

public ColorUIResource(Color c) 

Source Link

Document

Constructs a ColorUIResource .

Usage

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 www. ja v  a 2  s .co  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:Main.java

public static void main(String[] args) {
    UIManager.put("ComboBox.background", new ColorUIResource(Color.yellow));
    UIManager.put("JTextField.background", new ColorUIResource(Color.yellow));
    UIManager.put("ComboBox.selectionBackground", new ColorUIResource(Color.magenta));
    UIManager.put("ComboBox.selectionForeground", new ColorUIResource(Color.blue));
    new Main();/*from  www  .  j  a v  a  2  s .c  om*/
}

From source file:ColoredToolTipExample.java

public ColoredToolTipExample() {
    super("Colored ToolTip Example");

    UIManager.put("ToolTip.foreground", new ColorUIResource(Color.red));
    UIManager.put("ToolTip.background", new ColorUIResource(Color.yellow));

    JButton button = new JButton("Hello, world");
    button.setToolTipText("Red / Yellow");
    getContentPane().add(button);//from ww w  .  j  a  va 2  s.c  o  m
}

From source file:Main.java

public Main() {
    UIManager.put("TabbedPane.contentBorderInsets", new InsetsUIResource(1, 0, 0, 0));
    UIManager.put("TabbedPane.contentAreaColor", new ColorUIResource(Color.GREEN));
    UIManager.put("TabbedPane.focus", new ColorUIResource(Color.ORANGE));
    UIManager.put("TabbedPane.selected", new ColorUIResource(Color.YELLOW));
    UIManager.put("TabbedPane.darkShadow", new ColorUIResource(Color.DARK_GRAY));
    UIManager.put("TabbedPane.borderHightlightColor", new ColorUIResource(Color.LIGHT_GRAY));
    UIManager.put("TabbedPane.light", new ColorUIResource(Color.WHITE));
    UIManager.put("TabbedPane.tabAreaBackground", new ColorUIResource(Color.CYAN));
    UIManager.put("ToolTip.background", Color.WHITE);
    UIManager.put("ToolTip.border", new BorderUIResource(new LineBorder(Color.BLACK)));
    this.updateUI();

    this.setBackground(Color.BLUE);

    JPanel testPanel = new JPanel();
    testPanel.setLayout(new BorderLayout());
    testPanel.add(new JLabel("Hello World"), BorderLayout.NORTH);
    testPanel.add(new JTextArea("Looks nice out there :)"), BorderLayout.CENTER);

    JPanel testPanel2 = new JPanel();
    testPanel2.setLayout(new BorderLayout());
    testPanel2.add(new JLabel("Good Bye World"), BorderLayout.NORTH);
    testPanel2.add(new JTextArea("OK"), BorderLayout.CENTER);

    this.addTab("Hello World", testPanel);
    this.addTab("World", testPanel2);
}

From source file:Main.java

public ColorUIResource getWindowTitleInactiveBackground() {
    return new ColorUIResource(java.awt.Color.orange);
}

From source file:Main.java

public ColorUIResource getWindowTitleBackground() {
    return new ColorUIResource(java.awt.Color.orange);
}

From source file:Main.java

public ColorUIResource getPrimaryControlHighlight() {
    return new ColorUIResource(java.awt.Color.orange);
}

From source file:Main.java

public ColorUIResource getPrimaryControlDarkShadow() {
    return new ColorUIResource(java.awt.Color.orange);
}

From source file:Main.java

public ColorUIResource getPrimaryControl() {
    return new ColorUIResource(java.awt.Color.orange);
}

From source file:Main.java

public ColorUIResource getControlHighlight() {
    return new ColorUIResource(java.awt.Color.orange);
}