Skip to main content

Q: Y one ToolTipManager for ALL ToolTips in the system

21 replies [Last post]
kjc5664
Offline
Joined: 2004-03-04

Can any of the Sun Swing developers elaborate on why
this decision was made. The way it stands. If I want to
set the dismiss delay on one component. It affects ALL
the GUI components.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
viravan
Offline
Joined: 2003-06-23

>You could accomplish this by setting the tooltip text to
>null when the user starts typing and when the mouse moves
>set it to the non-null value.
>If we allowed you to plug in a custom ToolTipManager it could
>take care of all of this for you.

Hmmm.... the problem as Zander has put it is trying to figure out which component the mouse landed on. As far as a custom ToolTipManager goes, I've already taken care of that.

>I agree with Zander that you should also turn off the cursor.

What is this [b]cursor[/b] thingy you two are referring to.

BTW, changing the timer sounds like a winner!

Thanks,

Vira Van.

viravan
Offline
Joined: 2003-06-23

Just thought about the case of a disappearing cursor and the more I think about it the less I like it ... I'll probably end up with mouselisteners all over the place -- managing these listeners to ensure proper gc will not be a small task!

Vira Van.

viravan
Offline
Joined: 2003-06-23

Ok..... just an update on what I've done:

I've already subclassed various text components (JTextField, JTextArea, etc) each of which has its own processKeyBinding method. When a keyevent is detected, I simply call my own toolTipManager stopEnterTimer, like so:

[code]
public void stopEnterTimer() {
if (enterTimer.isRunning()) enterTimer.stop();
}
[/code]

Problem solved!

Thank you all.

Vira Van.

Uwe Wiedenbach
Offline
Joined: 2006-02-17

Hi,
you wrote that you use your own TooltipManager. How you do that ? I cannot derive from it.
I want to show a tooltip on a scrollbar when entering with the mouse and when moving the slider (also when pressing a scrollbar arrow button).

Kind regards,
Uwe

zander
Offline
Joined: 2003-06-13

> Hi,
> you wrote that you use your own TooltipManager. How
> you do that ? I cannot derive from it.
> I want to show a tooltip on a scrollbar when entering
> with the mouse and when moving the slider (also when
> pressing a scrollbar arrow button).

You are correct that there is no framework available to replace your tooltip manager. The implementation is not really great from an extention POV. I hope this will be fixed someday (Sun: just make the instance a protected non-final member in the ToolTipManger, please!)

Since these components don't normally have a tooltip what you want to do is to create a new 'manager' that will manage these components and nothing more. You can probably create a 20 lines new class for that.
The thing is that each component has to register itself with the manager (ToolTipManager.registerComponent()) so you want to do that with your components on your own manager and not on the ToolTipManager which setToolTipText does. Then do your thing with javax.swing.Timer objects etc.

scott.violet
Offline
Joined: 2006-02-17

> Hi:
>
> I guess we're all new to the forum in this community
> and I am not sure if I should just start a new topic
> or just piggyback on an existing topic dealing with a
> question of ToolTip.... Anyway, I have a question
> that's perhaps someone can answer:
>
> Supposed I have a data entry form with numerous
> textfields, each of which has its own ToolTipText.
> Generally, a user would click on one of the fields,
> move the mouse pointer away and start typing. If
> the mouse pointer happened to land in one of the
> other text fields, a ToolTip popup inevitably
> appears. Is there any way to prevent that from
> happening (i.e., tell the ToolTipManager not to
> display anything once a keyboard entry is
> detected)!

Excellent idea.
You could accomplish this by setting the tooltip text to
null when the user starts typing and when the mouse moves
set it to the non-null value.
If we allowed you to plug in a custom ToolTipManager it could
take care of all of this for you.
I agree with Zander that you should also turn off the cursor.

zander
Offline
Joined: 2003-06-13

> You could accomplish this by setting the tooltip text to
> null when the user starts typing and when the mouse moves
> set it to the non-null value.

I'm not sure that is the best solution since you don't know which textfield (or button for that matter) the pointer is going to end on.
What about setting the timeout (on the ToolTipManager) to a couple of days as soon as you start typing, since that timeout is set on a singleton it makes it a bit more robust.

zander
Offline
Joined: 2003-06-13

> Won't work. Because. The method would look this way.
>
>
> JComponent.setToolTipDismissDelay(long aDismissDelay){
> ToolTipManager.sharedInstance().setDismissDelay(aDismssDelay);
> }

Hey! Think different!

Just use your own ToolTipManager for this one component. It is a public class.
Override the setToolTipText as well for that one, though..

> I appologize to you.
> And everyone that has been reading this thread for
> doing a RANT. I just feel strongly that in this
> instance.

Ok, accepted, please count to 10 before pressing that 'post message' next time. Thanx.

zander
Offline
Joined: 2003-06-13

> Not MEANT to be used that way ??
> HUH ??

I'm not sure that I am the one you are replying to since I never said that, but lets just assume you meant me.
I'm trying to point out that your UI-design can take some alterations to take away the problem instead of putting on the band-aid you were trying to provide.

I find it rather insulting that you would start cursing and pointing badly at Swing/Sun (which I have no hand in). Those issues are entirely besides the point, leave them out of this.
Lets just say that in the future I (and probably others) will think twice about trying to help you create a better application.
Don't call me stupid if my answer is not the answer you want.

That said; just override the createToolTip on the relevant button to set your precious timeout..

kjc5664
Offline
Joined: 2004-03-04

Won't work. Because. The method would look this way.

JComponent.setToolTipDismissDelay(long aDismissDelay){

ToolTipManager.sharedInstance().setDismissDelay(aDismissDelay);

}

This has the effect of setting the same delay for ALL components in the system.
This was in fact my motivation for making the original POST. I appologize to you.
And everyone that has been reading this thread for
doing a RANT. I just feel strongly that in this instance. A very poor design
decision was made here.

jeff
Offline
Joined: 2003-06-10

I've not tried this, but you might try setting the dismiss delay on mouse enter of a given button, and restore it on mouse exit.

jeff

kjc5664
Offline
Joined: 2004-03-04

Excellent idea Jeff. And, thanks for keeping things in check.

scott.violet
Offline
Joined: 2006-02-17

> Can any of the Sun Swing developers elaborate on why
> this decision was made. The way it stands. If I want
> to set the dismiss delay on one component. It affects
> ALL the GUI components.

We didn't consider people wanting to change it per component.
To date you are the first person to request this feature. I suspect
rather than adding something like this it would be better to make
ToolTipManager pluggable, so that you could override all aspects
of the ToolTipManager. I encourage you to file an RFE for this
on the JDC, and for those that are interested to vote for it.

viravan
Offline
Joined: 2003-06-23

Hi:

I guess we're all new to the forum in this community and I am not sure if I should just start a new topic or just piggyback on an existing topic dealing with a question of ToolTip.... Anyway, I have a question that's perhaps someone can answer:

Supposed I have a data entry form with numerous textfields, each of which has its own ToolTipText. Generally, a user would click on one of the fields, move the mouse pointer away and start typing. If the mouse pointer happened to land in one of the other text fields, a ToolTip popup inevitably appears. Is there any way to prevent that from happening (i.e., tell the ToolTipManager not to display anything once a keyboard entry is detected)!

;o)

Vira Van

zander
Offline
Joined: 2003-06-13

Just as an alternative; the cursor should be made invisible as soon as the user starts typing and made visible again when the mouse is moved.
This feature has landed KDE some prices when it was first introduced quite some time ago.

Its a feature I have on my todo list for my own widgets, but I have not yet looked into how to do this correctly yet.

zander
Offline
Joined: 2003-06-13

From a usability point of view; this behavior is entirely correct.
As usual when I get 'strange' requests from developers I have to ask that you let a usability expert look at your GUI since the request points to a problem somewhere else.

kjc5664
Offline
Joined: 2004-03-04

I disagree with you completely. Lets say, that I have two JButtons each with an IconImage that displays what the respective
JButton can be used to purchase. Lets further say that
JButton1 represents the sale of one single grained item.
And, JButton2 represents the sale of a "composite" sale item that is made up of a collection of other items, but
sold under a single product number. I would want to
set the tool tip dismiss delay on JButton1 to be short so that
it simply displays the item name and price. I want to set the tool-tip dismiss delay of JButton2 to be much longer.
So that a sales person could correctly see all of the composite items that are part of this sale. From a software design perspective. The correct implementation is
letting each JComponent instance have it's own tool-tip text behavior. After all each JComponent has it's own tool-tip text. But the timing etc.. is common to all ??
This makes no sense to me. As an example of using one component that manages all component resources in the system. Imagine what it would be like to set the background color of one component. And have all components in the system have that same background color whether they want that color or not.

zander
Offline
Joined: 2003-06-13

I understand your point, but I'm afraid I don't agree with your proposal to make them dissapear after different timeouts.
I have two reasons for this:
1) The user is the one that asks for a tooltip since she puts the pointer there, the user expects the 'pointer for info' to be readable, but not be annoying (in your face). That is not different for content you have to read or for content that is a 'tip'.
Next to that is the always present usability rule [b]consistency[/b], don't [i]ever[/i] make apparently similar things bahave different.

2) You seem to want to provide information vital to the user via these tooltips (or at least one); they are not meant to be used that way. Please consider an extra panel with that info, or in worst case; popup that repeats the info and has an ok/cancel set of buttons.

kjc5664
Offline
Joined: 2004-03-04

Not MEANT to be used that way ??
HUH ??
What in the world does that mean. Ever heard of words like Creativity
and Innovation ??
It Sounds like you're attempting to explain away a POOR design decision.
I feel that a developer builds the app according to the user audience.
The user audience I'm addressing with my app. Wants no part of anything that
would slow down a Sale. And, having a dialog pop-up and dismissed every
time information is needed. Is to put it mildly. Atrocious. Having another panel that has this information is also, not very creative and takes up yet more real estate. The other thing is.
The JButton ISN'T behaving differently. It still registers a sale of an item,
and all the stuff that goes on behind the scenes etc... The only thing that is different is how much time the tool-tip stays visible. This is common sense.
It takes more time to read more lines of text. Providing for this is called robustness. I'm not interested in generalization here. If I were building
a framework or class library. I MIGHT agree with one of your assertions. But, I'm building to
suit the needs of my user audience. And, besides that. There is no argument that can explain away the
the OO issue. The ability to do what I want to do should be there. Does'nt matter if it's GOOD/BAD UI design. If I have JComponent.setToolTipText("someText");

I should also be able to say JComponent.setToolTTipTextDismissDelay(long);
and all the rest of the timing methods found in JToolTipManager.
On a closing note. Stop with the "It's not meant to be used that way" nonsense.
I'm sure that Mr. McNeely and creative people the world over would have a very difficult time agreeing with you.

jeff
Offline
Joined: 2003-06-10

Kevin, please dial back your language - you're starting to make things personal with Thomas instead of just sticking to the facts (or opinions, in this case).

jeff

kjc5664
Offline
Joined: 2004-03-04

You're right. My appologies to you Thomas.
I was ranting because. It felt to me like someone was attempting to stifle
my creativity.