Example usage for javax.swing JToolTip setBackground

List of usage examples for javax.swing JToolTip setBackground

Introduction

In this page you can find the example usage for javax.swing JToolTip setBackground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Tooltip");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel();
    panel.setToolTipText("<HtMl>Tooltip<br>Message");
    frame.add(panel, BorderLayout.CENTER);

    JButton button = new JButton("Hello, World") {
        public JToolTip createToolTip() {
            JToolTip tip = super.createToolTip();
            tip.setBackground(Color.YELLOW);
            tip.setForeground(Color.RED);
            return tip;
        }//from  w ww .j  a  v a  2s  . c om

        public boolean contains(int x, int y) {
            if (x < 100) {
                setToolTipText("x < 100");
            } else {
                setToolTipText("else");
            }
            return super.contains(x, y);
        }
    };

    button.setToolTipText("Hello, World");
    frame.add(button, BorderLayout.NORTH);

    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:org.rdv.ui.TimeSlider.java

/**
 * Creates the tooltip for the component. This changes the default tooltip by
 * setting a different border./* w  w w . j  a  va 2 s  .c  o m*/
 * 
 * @return  the tooltip created
 */
public JToolTip createToolTip() {
    JToolTip toolTip = super.createToolTip();
    toolTip.setBackground(Color.decode("#FFFFFC"));
    toolTip.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    return toolTip;
}