Web Hosting Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting
Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting
Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting

Alden Hosting provides professional, efficient, and reliable business-class Web hosting services to small- and medium-sized businesses.

WWW.

Call Us Toll-Free
(877) 256-0328

Outside USA
1 - (201) 505-0430

Web Hosting Welcome Web Hosting Web Hosting Plans Overview , Fund Raising, Fundraising, web hosting, website hosting, web site hosting Web Hosting Fund Raising, Fundraising, web hosting Web Hosting Resellers, web Hosting Web Hosting Web Design, web Hosting Web Hosting Extra Services,  web Hosting Web Hosting Traffic Booster, web hosting Web Hosting Traffic Booster, web hosting Web Hosting Technical Support,  web Hosting Web Hosting webmaster tips,  web Hosting Web Hosting 30 Day Money Back, web hosting Web Hosting Legal Notices for Web Hosting Web Hosting Glossary Computer Terms for web Hosting Web Hosting Contact Information - web hosting

Site Map

  Web Hosting Web Hosting Sign-Up   Web Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting    Web Hosting Resellers web hosting, website hosting, web site hosting   Web Hosting EZ Site Control Panel for web hosting,website hosting, web site hosting
How to Use Tool Tips (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)
Trail: Creating a GUI with JFC/Swing
Lesson: Using Swing Components
Section: How to Use Various Components
Home Page > Creating a GUI with JFC/Swing > Using Swing Components
How to Use Tool Tips
Creating a tool tip for any JComponent object is easy. Use the setToolTipText method to set up a tool tip for the component. For example, to add tool tips to three buttons, you add only three lines of code:
b1.setToolTipText("Click this button to disable the middle button.");
b2.setToolTipText("This middle button does not react when you click it.");
b3.setToolTipText("Click this button to enable the middle button.");
When the user of the program pauses with the cursor over any of the program's buttons, the tool tip for the button comes up. You can see this by running the ButtonDemo example, which is explained in How to Use Buttons, Check Boxes, and Radio Buttons. Here is a picture of the tool tip that appears when the cursor pauses over the left button in the ButtonDemo example.

ButtonDemo showing a tool tip.

For components such as tabbed panes that have multiple parts, it often makes sense to vary the tool tip text to reflect the part of the component under the cursor. For example, a tabbed pane might use this feature to explain what will happen when you click the tab under the cursor. When you implement a tabbed pane, you can specify the tab-specific tool tip text in an argument passed to the addTab or setToolTipTextAt method.

Even in components that have no API for setting part-specific tool tip text, you can generally do the job yourself. If the component supports renderers, then you can set the tool tip text on a custom renderer. The table and tree sections provide examples of tool tip text determined by a custom renderer. An alternative that works for all JComponents is creating a subclass of the component and overriding its getToolTipText(MouseEvent) method.

The Tool Tip API

Most of the API you need in order to set up tool tips belongs to the JComponent class, and thus is inherited by most Swing components. More tool tip API can be found in individual classes such as JTabbedPane. In general, those APIs are sufficient for specifying and displaying tool tips; you usually do not need to deal directly with the implementing classes JToolTip and ToolTipManager.

The following table lists the tool tip API in the JComponent class. For information on individual components' support for tool tips, see the how-to section for the component in question.

Tool Tip API in the JComponent class
Method Purpose
setToolTipText(String) If the specified string is not null, then this method registers the component as having a tool tip and, when displayed, gives the tool tip the specified text. If the argument is null, then this method turns off the tool tip for this component.
String getToolTipText() Returns the string that was previously specified with setToolTipText.
String getToolTipText(MouseEvent) By default, returns the same value returned by getToolTipText(). Multi-part components such as JTabbedPane, JTable, and JTree override this method to return a string associated with the mouse event location. For example, each tab in a tabbed pane can have different tool tip text.
Point getToolTipLocation(MouseEvent) Returns the location (in the receiving component's coordinate system) where the upper left corner of the component's tool tip appears. The argument is the event that caused the tool tip to be shown. The default return value is null, which tells the Swing system to choose a location.

Examples That Use Tool Tips

This table lists some examples that use tool tips and points to where those examples are described.

Example Where Described Notes
ButtonDemo This section and How to Use Buttons, Check Boxes, and Radio Buttons Uses a tool tip to provide instructions for a button.
IconDemo How to Use Icons Uses a tool tip in a label to provide name and size information for an image.
TabbedPaneDemo How to Use Tabbed Panes Uses tab-specific tool tip text specified in an argument to the addTab method.
TableRenderDemo Specifying Tool Tips for Cells Adds tool tips to a table using a renderer.
TableToolTipsDemo Specifying Tool Tips for Cells, Specifying Tool Tips for Column Headers Adds tool tips to a table using various techniques.
TreeIconDemo2 Customizing a Tree's Display Adds tool tips to a tree using a custom renderer.
ActionDemo How to Use Actions Adds tool tips to buttons that have been created using Actions.

Previous page: How to Use Tool Bars
Next page: How to Use Trees
Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting
Add to My Yahoo!

XML icon

Add to Google

 

 

 

 

 

 

 

 

 

 

 

http://alden-servlet-Hosting.com
JSP at alden-servlet-Hosting.com
Servlets at alden-servlet-Hosting.com
Servlet at alden-servlet-Hosting.com
Tomcat at alden-servlet-Hosting.com
MySQL at alden-servlet-Hosting.com
Java at alden-servlet-Hosting.com
sFTP at alden-servlet-Hosting.com
http://alden-tomcat-Hosting.com
JSP at alden-tomcat-Hosting.com
Servlets at alden-tomcat-Hosting.com
Servlet at alden-tomcat-Hosting.com
Tomcat at alden-tomcat-Hosting.com
MySQL at alden-tomcat-Hosting.com
Java at alden-tomcat-Hosting.com
sFTP at alden-tomcat-Hosting.com
http://alden-sftp-Hosting.com
JSP at alden-sftp-Hosting.com
Servlets at alden-sftp-Hosting.com
Servlet at alden-sftp-Hosting.com
Tomcat at alden-sftp-Hosting.com
MySQL at alden-sftp-Hosting.com
Java at alden-sftp-Hosting.com
sFTP at alden-sftp-Hosting.com
http://alden-jsp-Hosting.com
JSP at alden-jsp-Hosting.com
Servlets at alden-jsp-Hosting.com
Servlet at alden-jsp-Hosting.com
Tomcat at alden-jsp-Hosting.com
MySQL at alden-jsp-Hosting.com
Java at alden-jsp-Hosting.com
sFTP at alden-jsp-Hosting.com
http://alden-java-Hosting.com
JSp at alden-java-Hosting.com
Servlets at alden-java-Hosting.com
Servlet at alden-java-Hosting.com
Tomcat at alden-java-Hosting.com
MySQL at alden-java-Hosting.com
Java at alden-java-Hosting.com
sFTP at alden-java-Hosting.com
JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP at JSP.aldenWEBhosting.com Servlets at servlets.aldenWEBhosting.com Tomcat at Tomcat.aldenWEBhosting.com mysql at mysql.aldenWEBhosting.com Java at Java.aldenWEBhosting.com Web Hosts Portal Web Links Web Links Web Hosting JSP Solutions Web Links JSP Solutions Web Hosting Servlets Solutions Web Links Servlets Solutions Web Hosting Web Links Web Links . .
.
.
. .
. . . . jsp hosting servlets hosting web hosting web sites designed cheap web hosting web site hosting myspace web hosting