[SOLVED] Adding WebTooltip on a JTable

Discuss here any questions about the WebLaF library.
Bugs can be posted directly to GitHub issues tracker.

[SOLVED] Adding WebTooltip on a JTable

Postby GGK » Thu Aug 07, 2014 5:37 pm

Hi,

I'm exploring with Web Look and Feel and I try do add a WebToolTip on a Swing-JTable (not on a WebTable).

Doing like this..
Code: Select all
model = new DefaultTableModel (rows, title);
table = new JTable(model);

WebToolTip wtt = new WebToolTip();
wtt.setToolTipText("TEST");
wtt.add(table);


On that way, the tooltip wasn't shown... :oops:
How can I add a Tooltip to a component like a JTable.

Thanks

GGK
GGK
 
Posts: 7
Joined: Tue Aug 05, 2014 8:48 am

Re: Adding WebTooltip on a JTable

Postby mgarin » Thu Aug 07, 2014 6:21 pm

First of all - WebToolTip component is almost the same as the JToolTip and it shouldn't be used directly. You have to set tooltip text on the component instead:
Code: Select all
model = new DefaultTableModel (rows, title);
table = new JTable(model);
table.setToolTipText ( "TEST" );


That is in case you want to set tooltip to the whole component. In case you want to set tooltip to each cell within the JTable you will have to set it in the table renderer.

This stuff is actually a common Swing feature so I strongly you to read this article: http://docs.oracle.com/javase/tutorial/ ... oltip.html


P.S. In case you were talking about custom WebLaF tooltips - it is another story.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: Adding WebTooltip on a JTable

Postby GGK » Thu Aug 07, 2014 10:07 pm

Thanks for replying me...

I want to use a WebLaF ToolTip...

Instead the common way, i want do replace the JToolTip and set WebLaF ToolTip.
JButton button = new JButton("KLick me");
button.setToolTipText("Cooles LaF");

Does this work in any way?
GGK
GGK
 
Posts: 7
Joined: Tue Aug 05, 2014 8:48 am

Re: Adding WebTooltip on a JTable

Postby mgarin » Fri Aug 08, 2014 11:12 am

To set custom WebLaF tooltip you have to use TooltipManager:
Code: Select all
JButton button = new JButton("KLick me");
TooltipManager.setTooltip ( button, "Cooles LaF" );

There are also some additional options you may pass to tooltip aside the text.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: Adding WebTooltip on a JTable

Postby GGK » Fri Aug 08, 2014 2:35 pm

Thanks!

GGK
GGK
 
Posts: 7
Joined: Tue Aug 05, 2014 8:48 am

Re: Adding WebTooltip on a JTable

Postby mgarin » Fri Aug 08, 2014 6:37 pm

Always welcome :)
Marking this one solved.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg


Return to Questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron