Force JPopup to be always heavyweight (original) (raw)
Mario Torre neugens.limasoftware at gmail.com
Tue Apr 17 14:59:15 UTC 2012
- Previous message: Force JPopup to be always heavyweight
- Next message: Force JPopup to be always heavyweight
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2012/4/16 Pavel Porvatov <pavel.porvatov at oracle.com>:
Hello Pavel,
About the test, I'm not sure if you need something more specific, but I was thinking to simply test if when isLightWeightPopupEnabled is set we create an heavy or lightweight popup, any other ideas? That's a good way I think
Here is the webrev:
http://cr.openjdk.java.net/~neugens/6800513/
Note that MEDIUM_WEIGHT is still used in some cases (PopupFactory.getPopup):
if (owner == null || invokerInHeavyWeightPopup(owner)) {
popupType = HEAVY_WEIGHT_POPUP;
}
else if (popupType == LIGHT_WEIGHT_POPUP &&
!(contents instanceof JToolTip) &&
!(contents instanceof JPopupMenu)) {
popupType = MEDIUM_WEIGHT_POPUP;
}
I'm not sure if we want to replace this as well with full HW (I would do it, in fact).
Also I was thinking to have a very small optimization, if we are using an HW popups, there's no need to do this check:
// Check if the parent component is an option pane. If so we need to
// force a heavy weight popup in order to have event dispatching work
// correctly.
Component c = owner;
while (c != null) {
if (c instanceof JComponent) {
if (((JComponent)c).getClientProperty(
PopupFactory_FORCE_HEAVYWEIGHT_POPUP) ==
Boolean.TRUE) { popupType = HEAVY_WEIGHT_POPUP; break; } } else if (c instanceof Window) { Window w = (Window) c; if (!w.isOpaque() || w.getOpacity() < 1 || w.getShape() != null) { popupType = HEAVY_WEIGHT_POPUP; break; } } c = c.getParent(); }
We can save a loop and a couple of instanceof checks (although I remember we proved with Jim and Phil that instanceof don't really introduce any speed penalization).
What do you think?
Cheers, Mario
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF
IcedRobot: www.icedrobot.org Proud GNU Classpath developer: http://www.classpath.org/ Read About us at: http://planet.classpath.org OpenJDK: http://openjdk.java.net/projects/caciocavallo/
Please, support open standards: http://endsoftpatents.org/
- Previous message: Force JPopup to be always heavyweight
- Next message: Force JPopup to be always heavyweight
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]