Displaying Positional Tooltip Text: display different tooltip depending on the mouse pointer's location : JToolTip « Swing « Java Tutorial

Java Tutorial
1. Language
2. Data Type
3. Operators
4. Statement Control
5. Class Definition
6. Development
7. Reflection
8. Regular Expressions
9. Collections
10. Thread
11. File
12. Generics
13. I18N
14. Swing
15. Swing Event
16. 2D Graphics
17. SWT
18. SWT 2D Graphics
19. Network
20. Database
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web Services SOA
27. EJB3
28. Spring
29. PDF
30. Email
31. J2ME
32. J2EE Application
33. XML
34. Design Pattern
35. Log
36. Security
37. Apache Common
38. Ant
39. JUnit
Java
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Tutorial » Swing » JToolTip 
14. 72. 4. Displaying Positional Tooltip Text: display different tooltip depending on the mouse pointer's location
import javax.swing.JButton;
import javax.swing.JFrame;
public class DisplayingPositionalTooltip {
  public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton("Hello, World") {
      public boolean contains(int x, int y) {
        if (x < 50) {
          setToolTipText("AAAAAAAAA");
        else {
          setToolTipText("BBBBBBBBBBBBBB");
        }
        return super.contains(x, y);
      }
    };
    frame.add(button, "Center");
    frame.setSize(300200);
    frame.setVisible(true);
  }
}
14. 72. JToolTip
14. 72. 1. Adding JToolTip to componentAdding JToolTip to component
14. 72. 2. Creating HTML 3.2 formatted text tooltip: the text string begins with 'html' in any caseCreating HTML 3.2 formatted text tooltip: the text string begins with 'html' in any case
14. 72. 3. Creating Customized JToolTip Objects: customize and override its inherited public JToolTip createToolTip()
14. 72. 4. Displaying Positional Tooltip Text: display different tooltip depending on the mouse pointer's location
14. 72. 5. Displaying Mnemonics in tooltip textDisplaying Mnemonics in tooltip text
14. 72. 6. Label with tooltip
14. 72. 7. Use images in tooltips
14. 72. 8. Make a tool tips appear immediately
14. 72. 9. Use the default tool tip location
14. 72. 10. Setting the Location of a Tool Tip
14. 72. 11. Enabling and Disabling Tool Tips
14. 72. 12. Showing an Image in a Tool Tip
14. 72. 13. Italicize the second line
14. 72. 14. By default, the lines are left justified. Center the lines.
14. 72. 15. Showing Multiple Lines in a Tool Tip
14. 72. 16. Disable / enable application tool tips
14. 72. 17. Making Tool Tips Remain Visible
14. 72. 18. Set the location of the tool tip such that its nw corner coincides with the bottom center of the button
14. 72. 19. Modify the behaviour of the default JToolTip
14. 72. 20. Customizing a JToolTip Look and Feel
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.