|
|
Return
to JAVA JTree list |
Best books about JAVA programming:
|
JAVA JToolTip
This example shows how to add multiple line tooltips.
It includes three files:MultiLineToolTipExample.java, MultiLineToolTipUI.java and MultiLineToolTip.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.*;
public class MultiLineToolTipExample extends JFrame {
public MultiLineToolTipExample() {
super("Multi-Line ToolTip Example");
JButton button = new JButton ("Multiple line tooltip") {
public JToolTip createToolTip() {
MultiLineToolTip tip = new MultiLineToolTip();
tip.setComponent(this);
return tip;
}
};
UIManager.put("ToolTip.foreground",
new ColorUIResource(Color.red));
UIManager.put("ToolTip.background",
new ColorUIResource(Color.yellow));
button.setToolTipText("Hello\nworld");
getContentPane().add(button);
}
public static void main (String args[]) {
MultiLineToolTipExample f = new MultiLineToolTipExample();
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.setSize (300, 100);
f.show();
}
}
|
|
|