WebDocumentPane Tooltips

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

WebDocumentPane Tooltips

Postby lracosan » Tue Jun 23, 2015 5:24 am

Wondering if its possible to have tooltips for each tab in the WebDocumentPane. I tried to mess with it a little but could not get any tooltips to show up.
lracosan
 
Posts: 3
Joined: Tue Jun 23, 2015 5:22 am

Re: WebDocumentPane Tooltips

Postby mgarin » Tue Jun 23, 2015 1:20 pm

Here is a simple example of how that could be achieved:
Code: Select all
public class DocumentPaneExample
{
    public static void main ( final String[] args )
    {
        WebLookAndFeel.install ();

        final WebDocumentPane pane = new WebDocumentPane ();

        // Custom title component provider for tab button content
        pane.setTabTitleComponentProvider ( new DefaultTabTitleComponentProvider ()
        {
            public JComponent createTabTitleComponent ( final PaneData paneData, final DocumentData document )
            {
                final JComponent title = super.createTabTitleComponent ( paneData, document );
                TooltipManager.setTooltip ( title, WebLookAndFeel.getIcon ( 16 ), document.getTitle () );
                return title;
            }
        } );

        pane.openDocument ( new DocumentData ( "1", "Test tab 1", new WebLabel ( "" ) ) );
        pane.openDocument ( new DocumentData ( "2", "Test tab 2", new WebLabel ( "" ) ) );
        pane.openDocument ( new DocumentData ( "3", "Test tab 3", new WebLabel ( "" ) ) );

        TestFrame.show ( pane ).setSize ( new Dimension ( 400, 200 ) );
    }
}
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: WebDocumentPane Tooltips

Postby lracosan » Tue Jun 23, 2015 7:36 pm

I have tried the example and it does indeed work. However clicking on the tabs does nothing now. But when you comment out the setToolTip(...) line it behaves as it should.
lracosan
 
Posts: 3
Joined: Tue Jun 23, 2015 5:22 am

Re: WebDocumentPane Tooltips

Postby mgarin » Wed Jun 24, 2015 1:12 pm

Yes, this is indeed the case - didn't notice it because you can still choose tab by pressing on the side.
That happens because mouse listener added by tooltip is blocking events from going under the tab component.

I have added some changes to fix this problem, but those changes will only be available in the final v1.29 release. For now I can suggest adding similar fix right in the title provider:
Code: Select all
public class DocumentPaneExample
{
    public static void main ( final String[] args )
    {
        WebLookAndFeel.install ();

        final WebDocumentPane pane = new WebDocumentPane ();

        // Custom title component provider for tab button content
        pane.setTabTitleComponentProvider ( new DefaultTabTitleComponentProvider ()
        {
            public JComponent createTabTitleComponent ( final PaneData paneData, final DocumentData document )
            {
                final JComponent title = super.createTabTitleComponent ( paneData, document );
                title.addMouseListener ( new MouseAdapter ()
                {
                    public void mousePressed ( final MouseEvent e )
                    {
                        paneData.setSelected ( document );
                    }
                } );
                TooltipManager.setTooltip ( title, WebLookAndFeel.getIcon ( 16 ), document.getTitle () );
                return title;
            }
        } );

        pane.openDocument ( new DocumentData ( "1", "Test tab 1", new WebLabel ( "" ) ) );
        pane.openDocument ( new DocumentData ( "2", "Test tab 2", new WebLabel ( "" ) ) );
        pane.openDocument ( new DocumentData ( "3", "Test tab 3", new WebLabel ( "" ) ) );

        TestFrame.show ( pane ).setSize ( new Dimension ( 400, 200 ) );
    }
}
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: WebDocumentPane Tooltips

Postby mgarin » Wed Jun 24, 2015 1:19 pm

I have also added a separate issue on GitHub for this case:
https://github.com/mgarin/weblaf/issues/308
You can track it to be notified as soon as fix is released.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: WebDocumentPane Tooltips

Postby lracosan » Wed Jun 24, 2015 9:52 pm

Ah, I see. Thank you.
lracosan
 
Posts: 3
Joined: Tue Jun 23, 2015 5:22 am


Return to Questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron