Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8905035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:17:22+00:00 2026-06-15T02:17:22+00:00

I need to programically show tooltip for my button2 when it gets focus. (I

  • 0

I need to programically show tooltip for my button2 when it gets focus. (I press Tab as intially focus at button1)

            JButton button = new JButton("Button 1");

            JButton button2 = new JButton("Button 2");
            button2.setToolTipText("tooltip2");
            button2.addFocusListener(new FocusListener());

I refer the code by @camickr

private class FocusListener extends FocusAdapter {
 public void focusGained(FocusEvent e)
 {
    JComponent component = (JComponent)e.getSource();
    Action toolTipAction = component.getActionMap().get("postTip");

but toolTipAction is set null.

I have printed all the entries of ActionMap using this code

        ActionMap actionMap = component.getActionMap();
        Object[] actionMapKeys = actionMap.allKeys();

        for (int i = 0; i < actionMapKeys.length; i++) {
            Object key = actionMapKeys[i];
            System.out.println(key.toString() + " : " + actionMap.get(key).toString());
        }

This is what it gives me

pressed : javax.swing.plaf.basic.BasicButtonListener$Actions@49cf9f
released : javax.swing.plaf.basic.BasicButtonListener$Actions@1de0b5e

So how can I call this code if I got toolTipAction null?

ActionEvent postTip = new ActionEvent(component, ActionEvent.ACTION_PERFORMED, "");
toolTipAction.actionPerformed(postTip);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:17:23+00:00Added an answer on June 15, 2026 at 2:17 am

    actuall I want to show tooltip on some network event, which has
    nothing to do with mouse. but I have started experiments with focus
    gained by Tab key

    • use JWindow (undecorated JDialog) or JLabel instead of ToolTip, examples for JLabel by @Guillaume Polet and here

    • you can to lay this container to the Mouse Cursor possition or to stick to absolute coordinates, Point to the visible GUI

    • standard could be (can be annoying) see SystemTray and TrayIcon#displayMessage

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to programatically append to a multi-page TIFF or PDF a new image.
I need to create button programatically with an image for normal and highlighted state
I need to show some html code in TextBox. this is my TextBox description:
i need to achieve that, show the last tweets of a programatically given user.
i am using mxgraph to show the process. I need to select a edge
I need to programatically encrypt a directory of files, like in a .zip or
I am in a need of programatically convert an Word-XML file into a RTF
I have a WPF app in which I need to programatically manipulate at runtime.
I need to be able to programatically expand users' search expressions such as: X
I have a RichTextBox and I add some texts programatically. I need to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.