b9703
b9703

Reputation: 107

Java get mouseover tooltip text

Is it possible in java (or any other language that you know of) to get tool tip text (on mouseover). For example you mouseover something in an arbitrary application and a tiny tooltip pops up with some info. Can this be returned as a string to a program. It seems possible, i dont see why not but im no expert. Any help would be appreciated. Thanks.

Upvotes: 4

Views: 4773

Answers (3)

Diyarbakir
Diyarbakir

Reputation: 2099

Have a look at How to Use Tool Tips.

Also see JComponent getTooltipText() method.

Upvotes: 2

Priyamal
Priyamal

Reputation: 2969

JButton b = new JButton("button1");
b.setToolTipText("click here to submit");

here is an example on how to add a tooltop to a jbutton. but here is the thing you dont have to write action listners to your button so that pop menu will become visible on mouse over . tooltip text will be automatically work on mouseOver.

Upvotes: 3

dryairship
dryairship

Reputation: 6077

All the classes which extend JComponent have these functionalities.

  • You do :

    comp.setToolTipText("HEY!");
    

    to set the text.

  • You do :

    String tt = comp.getToolTipText();
    

    to get the text.

Upvotes: 3

Related Questions