Link to home
Start Free TrialLog in
Avatar of hapciu
hapciu

asked on

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 ?
Avatar of edwardiii
edwardiii

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)?
Avatar of hapciu

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of edwardiii
edwardiii

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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:)
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).
Avatar of Mayank S
You should probably change the L&F before showing the pop-up.
Avatar of hapciu

ASKER

sorry for the delay
thanks
Thank you;)