Example usage for javax.swing JToolTip setForeground

List of usage examples for javax.swing JToolTip setForeground

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The foreground color of the component.")
public void setForeground(Color fg) 

Source Link

Document

Sets the foreground color of this component.

Usage

From source file:Main.java

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

    JButton b1 = new JButton("Button 1") {
        public JToolTip createToolTip() {
            JToolTip tip = super.createToolTip();
            tip.setForeground(Color.YELLOW);
            return tip;
        }/*from ww w.  j  a  v  a2s  .c o  m*/

        public Point getToolTipLocation(MouseEvent event) {
            return new Point((event.getX() + 100), (event.getY() + 100));
        }
    };
    b1.setToolTipText("HELLO");
    frame.add(b1, BorderLayout.NORTH);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

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;
        }/*www.j  av a  2 s  .com*/

        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);
}