Force JPopup to be always heavyweight (original) (raw)
Pavel Porvatov pavel.porvatov at oracle.com
Mon Apr 2 14:21:53 UTC 2012
- Previous message: JSeparator rendered incorrectly on Windows 7
- Next message: Force JPopup to be always heavyweight
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Mario,
I'd suggest to change the javax.swing.JPopupMenu#getPopup method:
if (isLightWeightPopupEnabled()) {
popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
}
else {
popupFactory.setPopupType(PopupFactory.HEAVY_WEIGHT_POPUP);
// Replaced MEDIUM_WEIGHT_POPUP }
I don't see any regressions, what do you think about that?
Regards, Pavel
Hi all,
Recently I came across this bug on our bug database: https://bugzilla.redhat.com/showbug.cgi?id=658654 This is actually a long standing issue that bothered me too for quite some time, since the net result is that Java applications look weird in some situation (specifically with the native LAF, but also with the default ones). I think a quick and easy solution that would preserve backward compatibility would be to add a system property that allows forcing heavy weight rather then medium weight behaviour for popup windows. Most of the code is already in place, so probably the changes could either go in JPopupMenu.getPopup with the additional advantage of being quite circumscribed, for example: PopupFactory popupFactory = PopupFactory.getSharedInstance(); if (isLightWeightPopupEnabled()) { popupFactory.setPopupType(PopupFactory.LIGHTWEIGHTPOPUP); } else if (forceAlwaysHWMenues()) { popupFactory.setPopupType(PopupFactory.HEAVYWEIGHTPOPUP); } else { popupFactory.setPopupType(PopupFactory.MEDIUMWEIGHTPOPUP); } or in a more general place forcing this to all the popup components to be HW. This change could be for example in JPopupFactory.getPopupType, right before the beginning of the method, for example: if (owner == null || invokerInHeavyWeightPopup(owner) || getProperty(PopupFactoryFORCEHEAVYWEIGHTPOPUP) { popupType = HEAVYWEIGHTPOPUP; } else if (popupType == LIGHTWEIGHTPOPUP&& !(contents instanceof JToolTip)&& !(contents instanceof JPopupMenu)) { popupType = MEDIUMWEIGHTPOPUP; } I personally don't see much risk for either, but the latter has definitely more impact, so having things local to JPopupMenu seems better (disclaimer, I didn't try those changes, so maybe more tweaking is needed). What do you think? I would propose those changes for JKD8 of course. Cheers, Mario P.S. I'm not sure if I should include the AWT team in the loop too.
- Previous message: JSeparator rendered incorrectly on Windows 7
- Next message: Force JPopup to be always heavyweight
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]