[SOLVED] WebPopupMenu getPreferredSize different values

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

[SOLVED] WebPopupMenu getPreferredSize different values

Postby Abu Abdullah » Thu Oct 17, 2013 4:52 pm

Hi again,

For the first show, WebPopupMenu getPreferredSize().width will give different value than the second time. for the below code it will give:
59
67


Code: Select all
class Test extends JFrame
{
   public Test()
   {
     final WebPopupMenu p = new WebPopupMenu();
        p.add(new JMenuItem("Test"));
      
      DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
      root.add(new DefaultMutableTreeNode("Child 1"));
      final JTree tree = new JTree(root);

      tree.addMouseListener(new MouseAdapter()
      {
         public void mouseReleased(MouseEvent m)
         {
            System.out.println(p.getPreferredSize().width);
                                // p.updateUI();
            p.show(tree, m.getX()-p.getPreferredSize().width, m.getY());
         }
      });
     setDefaultCloseOperation(EXIT_ON_CLOSE);
     getContentPane().add(new JScrollPane(tree));
     pack();
     setVisible(true);
   }
   
   public static void main(String args[])
   {
     WebLookAndFeel.install();
     SwingUtilities.invokeLater(new Runnable(){public void run(){new Test();}});
   }
}
Abu Abdullah
 
Posts: 41
Joined: Tue Apr 17, 2012 12:11 pm

Re: WebPopupMenu getPreferredSize different values

Postby mgarin » Thu Oct 17, 2013 5:09 pm

That happens due to additional left/right margin applied to menu items when popup menu is displayed.

I know that this might cause some issues when displaying RTL menus since popup menu preferred size is required to display it properly. I will be changing the margin update mechanism a bit to fix this issue.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: WebPopupMenu getPreferredSize different values

Postby Abu Abdullah » Thu Oct 17, 2013 5:17 pm

it also happens with LTR as well as in the above code
Abu Abdullah
 
Posts: 41
Joined: Tue Apr 17, 2012 12:11 pm

Re: WebPopupMenu getPreferredSize different values

Postby mgarin » Thu Oct 17, 2013 5:24 pm

I didn't say it doesn't happen with LTR, i just said that popup menu preferred size is usually required for its positioning with LTR orientation or in some other rare cases :)
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: WebPopupMenu getPreferredSize different values

Postby mgarin » Mon Oct 28, 2013 8:45 pm

Fix for this issue is not yet done, so its not available in v1.25.
Just in case you will be looking for it...
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: WebPopupMenu getPreferredSize different values

Postby Abu Abdullah » Sun Jul 13, 2014 9:43 pm

Hi Mikle,
Any updates on this issue.
Abu Abdullah
 
Posts: 41
Joined: Tue Apr 17, 2012 12:11 pm

Re: WebPopupMenu getPreferredSize different values

Postby mgarin » Wed Jul 16, 2014 11:24 am

Somehow I got this topic out of sight - this issue was actually fixed a few releases ago.
Menu should now always have a set preferred size that doesn't change after display.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: [SOLVED] WebPopupMenu getPreferredSize different values

Postby Abu Abdullah » Wed Jul 16, 2014 5:37 pm

thanks for closing this bug
Abu Abdullah
 
Posts: 41
Joined: Tue Apr 17, 2012 12:11 pm

Re: [SOLVED] WebPopupMenu getPreferredSize different values

Postby mgarin » Thu Jul 17, 2014 2:56 pm

No problem :)
Its just hard to track uncategorized issues here so I missed this one.
Apparently it was fixed with one of the menu improvements along with the painters support implementation.
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 2 guests

cron