• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

changing L&F for popup

I have a popup menu that I show when the user presses a button on my UI.
The problem is when the L&F gets changed and I do

UIManager.setLookAndFeel(..);
SwingUtilities.updateComponentTreeUI(mainFrame);

all my components get updated to the new L&F except for the popup. Is there a way to fix this ?
0
hapciu
Asked:
hapciu
1 Solution
 
edwardiiiCommented:
Hi, hapciu.

If the pop-up is supposed to stay up after the user changes the LookAndFeel, would it be an option for you to close/re-open the popup so the new LookAndFeel can take effect (on the pop-up)?
0
 
hapciuAuthor Commented:
it's not supposed to stay open - so it isn't shown while the LF changes. but the next time I show it - it still has the old LF

thanks
0
 
edwardiiiCommented:
Please ignore my recommendation to reopen/reinvoke your popup.  On my JFrame with a "jPopupMenu1" item, this changed the format of everything including the visible pop-up menu:

    try
        {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            SwingUtilities.updateComponentTreeUI(this);
            SwingUtilities.updateComponentTreeUI(jPopupMenu1);
        }
       
        catch (Exception e)
        {
            //your code, if any;
        }



 SwingUtilities.updateComponentTreeUI(this);
     SwingUtilities.updateComponentTreeUI(jPopupMenu1);
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
edwardiiiCommented:
To be more clear, even if you use your code "SwingUtilities.updateComponentTreeUI(mainFrame);" instead of my version with "this", as long as you include the following line of code,
your jPopup will retain the changed LookAndFeel, no matter how many times you subsequently open/close it:

     SwingUtilities.updateComponentTreeUI(jPopupMenu1);

Just substitute "jPopupMenu1" with the name of your jPopupMenu:)
0
 
aozarovCommented:
BTW, the reason for that is:
SwingUtilities.updateComponentTreeUI(component) will call updateUI on this component and each one of its children.
JPopupMenu is not a child of your frame (you never add it to your frame nor to its children).
0
 
Mayank SAssociate Director - Product EngineeringCommented:
You should probably change the L&F before showing the pop-up.
0
 
hapciuAuthor Commented:
sorry for the delay
thanks
0
 
edwardiiiCommented:
Thank you;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now