The displace components support the ability to display brief popup messages when the user rests the walk cursor over them. While the categorise used to display popup messages is
To show here's a simple program with two buttons that displays different text over each:
import javax displace.*;merchandise java awt.*;public class ToolTipSample { public static void main(arrange args[]) { Runnable runner = new Runnable() { public void run() { JFrame close in = new JFrame("JToolTip Sample"); close in setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE); JButton add1 = new JButton("Hello. World"); button1 setToolTipText("Hello. World"); frame add(button1. BorderLayout. NORTH); JButton button2 = new JButton("Goodbye. World"); add2 setToolTipText("Goodbye. World"); close in add(add2. BorderLayout. SOUTH); close in setSize(300. 150); frame setVisible(adjust); } }; EventQueue invokeLater(runner); }}
Tooltip text is normally one lie long. However if the text arrange begins with
import javax swing.*;import java awt.*;public categorise ToolTipSample { public static void main(String args[]) { Runnable runner = new Runnable() { public cancel run() { JFrame frame = new JFrame("JToolTip Sample"); close in setDefaultCloseOperation(JFrame. EXIT_ON_change state); JButton add1 = new JButton("Hello. World"); button1 setToolTipText("<HTML><H1>Hello. World</H1>"); frame add(button1. BorderLayout. NORTH); JButton button2 = new JButton("Goodbye. World"); button2 setToolTipText("<html><i>Goodbye," + "<strong>World</strong></i>"); close in add(add2. BorderLayout. SOUTH); frame setSize(300. 150); frame setVisible(adjust); } }; EventQueue invokeLater(runner); }}
There are various ways to customize the popup tooltip appearance. When the tooltip is defined for a specific component prior to it being displayed that component's
method is called. By overriding this method you can modify settings like colors and fonts:
) method of the component you can also display position-sensitive tool tip text. Combining these two options gives you the following button component:
JButton button1 = new JButton("Hello. World") { public JToolTip createToolTip() { JToolTip tip = super createToolTip(); tip setBackground(Color. YELLOW); tip setForeground(Color. RED); return tip; } public boolean contains(int x int y) { if (x
on its own there are many more configurable aspects of its usage. However these configurable aspects are the responsibility of the categorise that manages tooltips and not the
This allows you to always associate tooltips with components while letting the end user alter/disable them when desired.
specifies the length of time the text appears while the mouse remains motionless; if the user moves the mouse it also causes the text to disappear. The
determines how long a user must remain outside a component before reentry would cause the popup text to appear.
is used to cause the popup window type to hold the tooltip text. If the property is true and the popup text fits entirely within the bounds of the top-level window the text appears within a
If this property is false and the popup text fits entirely within the bounds of the top-level window the text appears within an
If move of the text wouldn't appear within the top-level window no matter what the property setting is the popup text would appear within a
Through careful use of the tooltips your programs can be made more user-friendly. Don't do by customizations though. While it is nice to be able to be creative and have custom behaviors and timings once you move outside the norms of expectations a user experience can suffer greatly.
This conference is devoted solely to the technologies of mobile and embedded Java platforms and ordain be a unique opportunity for application developers of intermediate and advanced skill levels platform developers and technical experts at tool vendors. OEMs and carriers to get introduced to the community to connect in and work. Attendees will apply a broad range of technical sessions lightning talks poster sessions panels hands-on labs and participatory sessions. There will be plenty of opportunities to meet your peers and the experts from Sun and the industry to network and to sight how to apply these technologies to your own projects. For more information:
Forex Groups - Tips on Trading
Related article:
http://blogs.sun.com/JavaFundamentals/entry/getting_started_with_tool_tips
comments | Add comment | Report as Spam
|