[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[albireo-dev] Partial fix for a tooltip issue
|
On some platforms (e.g. Windows), Swing does not, by default, display
tooltips for inactive windows. In the case of Swing/SWT integration and
embedded AWT/Swing frames, this behavior is noticeably different than
standard SWT.
I've committed a simple, partial fix which reconfigures the Swing
behavior to be consistent with SWT. This configurability is only
available on JDK 1.6 and higher. I haven't enclosed it in a version
check because it is conceivable that the fix will be backported to a
future 1.5 mainenance. (Unlikely but conceivable)
I don't know if there is a different workaround for JDK 1.5.
For more information, see:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178004
https://bugs.eclipse.org/bugs/show_bug.cgi?id=186857
### Eclipse Workspace Patch 1.0
#P org.eclipse.albireo.core
Index: src/org/eclipse/albireo/core/LookAndFeelHandler.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/core/LookAndFeelHandler.java,v
retrieving revision 1.9
diff -u -r1.9 LookAndFeelHandler.java
--- src/org/eclipse/albireo/core/LookAndFeelHandler.java 29 Apr 2008 18:54:11 -0000 1.9
+++ src/org/eclipse/albireo/core/LookAndFeelHandler.java 27 May 2008 23:06:51 -0000
@@ -118,9 +118,10 @@
lafChoice = choice;
}
- // ------------------------------------------------------------------------
+ // -------------------------- Options ----------------------------------------------
private boolean isDefaultSwtFontPropagated = true;
+ private boolean isTooltipAlwaysShown = true;
/**
* Returns whether SWT default font changes are automatically propagated to
@@ -154,6 +155,36 @@
isDefaultSwtFontPropagated = val;
}
+ /**
+ * Returns whether Swing's default tooltip behavior will be changed to
+ * be more consistent with SWT. See {@link #setTooltipAlwaysShown(boolean)}
+ * for more information.
+ *
+ * @return the current isTooltipAlwaysShown flag
+ */
+ public boolean isTooltipAlwaysShown() {
+ return isTooltipAlwaysShown;
+ }
+
+ /**
+ * Configures the tooltip behavior for Swing components. On some platforms,
+ * Swing tooltips are not shown for inactive windows (including embedded
+ * frames). By setting the flag to <code>true</code>, (the default value)
+ * this Swing behavior is changed and tooltips are shown, whether or not
+ * the window is inactive. This makes the Swing tooltips more consistent
+ * with SWT tooltips.
+ * <p>
+ * Note: This change of behavior currently works only on JDK 1.6 and higher.
+ * See sun bug <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178004">
+ * 6178004</a>
+ *
+ * @param isTooltipAlwaysShown the new isTooltipAlwaysShown value to set
+ */
+ public void setTooltipAlwaysShown(boolean isTooltipAlwaysShown) {
+ this.isTooltipAlwaysShown = isTooltipAlwaysShown;
+ }
+
+
// ========================================================================
// Overridable API
@@ -169,6 +200,13 @@
IllegalAccessException,
UnsupportedLookAndFeelException {
assert EventQueue.isDispatchThread(); // On AWT event thread
+
+ if (isTooltipAlwaysShown) {
+ // Try to turn on tooltips for inactive AWT windows. This is not the default
+ // behavior on some platforms. Also, note that it will only work in
+ // JDK1.6+
+ UIManager.put("ToolTipManager.enableToolTipMode", "allWindows");
+ }
// If the user has specified the Swing look&feel through the
// system property, and the application has also specified the