-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tooltips does not work on list elements #180
Comments
Unfortunately WebLaF custom tooltips doen't work the same way Swing tooltips work - they have different underlying behavior and won't appear for renderer components (doesn't matter whether its tree, table or list renderer). WebLaF custom tooltips are bound to components and displayed according to their positions. Swing tooltips do the same in most cases but they use a tricky workaround for the renderers case since each renderer is basically just one component updated multiply times in a row to display all cells. Registering WebLaF tooltips like you did in the example in the renderer call will only attach that tooltip to the renderer component but it will never be displayed, because renderer components aren't actually displayed but manually painted onto renderer pane of the list. With later updates there will be an additional settings for WebList, WebTree and WebTable to provide something like tooltip provider where you will be able to pass your custom tooltip for each cell in a similar way you do in Swing cell renderers. |
I might be able to include that improvement into v1.29 update. |
Ok, thanks a lot for clarifying. It's quite important feature for our project, I would appreciate it a lot. |
…ooltips [ #180 ] Simplified "setPreferredSize" method is now available for most of Web-components
#180 ] Minor improvements for WebTree and WebList rollover behavior
Complete implementation of this feature for list, tree and table is now available in source code. All three components ( Here are some test examples for this new feature: public class WebListTooltip
{
public static void main ( final String[] args )
{
WebLookAndFeel.install ();
final WebList list = new WebList ( new String[]{ "Item 1", "Item 2", "Item 3", "Item 4" } );
list.setVisibleRowCount ( 4 );
list.setToolTipProvider ( new ListToolTipProvider ()
{
@Override
public String getToolTipText ( final WebList component, final Object value, final int index, final int column,
final boolean isSelected )
{
return "Cell value: " + value;
}
} );
TestFrame.show ( new WebScrollPane ( list ), 150 );
}
} public class WebTreeTooltip
{
public static void main ( final String[] args )
{
WebLookAndFeel.install ();
final WebTree tree = new WebTree ();
tree.setToolTipProvider ( new TreeToolTipProvider<UniqueNode> ()
{
@Override
public String getToolTipText ( final WebTree<UniqueNode> tree, final UniqueNode node, final int row, final boolean isSelected )
{
return "Node: " + node;
}
} );
TestFrame.show ( new WebScrollPane ( tree ), 150 );
}
} public class WebTableTooltip
{
public static void main ( final String[] args )
{
WebLookAndFeel.install ();
final Object[][] data = { { "1", "2", "3" }, { "d1", "d2", "d3" } };
final WebTable table = new WebTable ( data, new Object[]{ "c1", "c2", "c3" } );
table.setToolTipProvider ( new TableToolTipProvider ()
{
@Override
public String getToolTipText ( final WebTable component, final Object value, final int index, final int column,
final boolean isSelected )
{
return "Cell value: " + value;
}
} );
TestFrame.show ( new WebScrollPane ( table ), 150 );
}
} |
Perfect. Thanks a lot! |
I will also be adding more features and settings for those with time, so feel free to ask for any settings you might want to have there as those implementation are just basic ones and can be easily improved. |
It's way OT, but one thing that bothers me with JList a lot is the way how are list items treated when they're layout in row wrap, e.g.
I would appreciate if there could be some setting which will allow to set how many list items in one row should be visible (there is only setting for how many rows in one column should be visible) with item size recalculation whenever size of list change. |
Recalculation of the items size is an issue there indeed and can't be solved that easily. |
That hack with For the resize problem approach I use |
Will see what can be done with the next update :) |
Updated pre-release artifacts are now available here: |
If custom cell renderer is made for
List
component and tooltip is registered to cell element, tooltip is not shown (regular java basicsetTooltip()
method works).Here is SSCCE
The text was updated successfully, but these errors were encountered: