浏览代码

Non-opaque tabbedpanes for GTK too.

Change-Id: Ie4a8c64c6dc5093034e238a9028eef1c0eaf4078
Reviewed-on: http://gerrit.dmdirc.com/2622
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8
Greg Holmes 11 年前
父节点
当前提交
eda3c0bb95
共有 2 个文件被更改,包括 58 次插入20 次删除
  1. 55
    18
      src/com/dmdirc/addons/ui_swing/UIUtilities.java
  2. 3
    2
      src/com/dmdirc/addons/ui_swing/textpane/TextPaneUI.java

+ 55
- 18
src/com/dmdirc/addons/ui_swing/UIUtilities.java 查看文件

@@ -66,6 +66,27 @@ import net.miginfocom.layout.PlatformDefaults;
66 66
 @SuppressWarnings("PMD.UnusedImports")
67 67
 public final class UIUtilities {
68 68
 
69
+    /**
70
+     * GTK LAF class name.
71
+     */
72
+    private static final String GTKUI
73
+            = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
74
+    /**
75
+     * Nimbus LAF class name.
76
+     */
77
+    private static final String NIMBUSUI
78
+            = "sun.swing.plaf.nimbus.NimbusLookAndFeel";
79
+    /**
80
+     * Windows LAF class name.
81
+     */
82
+    private static final String WINDOWSUI
83
+            = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
84
+    /**
85
+     * Windows classic LAF class name.
86
+     */
87
+    private static final String WINDOWSCLASSICUI
88
+            = "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
89
+
69 90
     /** Not intended to be instantiated. */
70 91
     private UIUtilities() {
71 92
     }
@@ -283,10 +304,36 @@ public final class UIUtilities {
283 304
      * @return true iif the LAF is GTK
284 305
      */
285 306
     public static boolean isGTKUI() {
286
-        return "com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(UIManager
287
-                .getLookAndFeel().getClass().getName());
307
+        return GTKUI.equals(UIManager.getLookAndFeel().getClass().getName());
288 308
     }
289 309
 
310
+    /**
311
+     * Check if we are using the Nimbus look and feel.
312
+     *
313
+     * @return true iif the LAF is Nimbus
314
+     */
315
+    public static boolean isNimbusUI() {
316
+        return NIMBUSUI.equals(UIManager.getLookAndFeel().getClass().getName());
317
+    }
318
+
319
+    /**
320
+     * Check if we are using the new Windows Look and Feel.
321
+     *
322
+     * @return true iif the current LAF is Windows
323
+     */
324
+    public static boolean isWindowsNewUI() {
325
+        return WINDOWSUI.equals(
326
+                UIManager.getLookAndFeel().getClass().getName());
327
+    }
328
+
329
+    /**
330
+     * Check if we are using the new Windows Classic Look and Feel.
331
+     *
332
+     * @return true iif the current LAF is Windows Classic
333
+     */
334
+    public static boolean isWindowsClassicUI() {
335
+        return WINDOWSCLASSICUI.equals(UIManager.getLookAndFeel().getClass().getName());
336
+    }
290 337
 
291 338
     /**
292 339
      * Check if we are using one of the Windows Look and Feels.
@@ -294,29 +341,19 @@ public final class UIUtilities {
294 341
      * @return True iff the current LAF is "Windows" or "Windows Classic"
295 342
      */
296 343
     public static boolean isWindowsUI() {
297
-        final String uiname = UIManager.getLookAndFeel().getClass().getName();
298
-        final String windows =
299
-                "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
300
-        final String classic =
301
-                "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
302
-
303
-        return windows.equals(uiname) || classic.equals(uiname);
344
+        return isWindowsNewUI() || isWindowsClassicUI();
304 345
     }
305 346
 
306 347
     /**
307
-     * Get the value to pass to set Opaque on items being added to a JTabbedPane.
348
+     * Get the value to pass to set Opaque on items being added to a
349
+     * JTabbedPane.  Currently they need to be transparent on Windows
350
+     * (non classic), Apple, Nimbus and GTK.
308 351
      *
309
-     * @return True iff the current LAF is not Windows or OS X.
352
+     * @return True if tabbed panes should be opaque
310 353
      * @since 0.6
311 354
      */
312 355
     public static boolean getTabbedPaneOpaque() {
313
-        final String uiname = UIManager.getLookAndFeel().getClass().getName();
314
-        final String windows =
315
-                "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
316
-        final String nimbus = "sun.swing.plaf.nimbus.NimbusLookAndFeel";
317
-
318
-        return !(windows.equals(uiname) || Apple.isAppleUI() || nimbus.equals(
319
-                uiname));
356
+        return !(isWindowsNewUI() || Apple.isAppleUI() || isNimbusUI() || isGTKUI());
320 357
     }
321 358
 
322 359
     /**

+ 3
- 2
src/com/dmdirc/addons/ui_swing/textpane/TextPaneUI.java 查看文件

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.textpane;
24 24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
26
+
25 27
 import javax.swing.BorderFactory;
26 28
 import javax.swing.JComponent;
27 29
 import javax.swing.UIManager;
@@ -37,8 +39,7 @@ public class TextPaneUI extends ComponentUI {
37 39
     @Override
38 40
     public void installUI(final JComponent c) {
39 41
         Border border;
40
-        if (UIManager.getLookAndFeel().getClass().getName().equals(
41
-                "com.sun.java.swing.plaf.gtk.GTKLookAndFeel")) {
42
+        if (UIUtilities.isGTKUI()) {
42 43
             border = UIManager.getBorder("TitledBorder.border");
43 44
         } else {
44 45
             border = UIManager.getBorder("TextField.border");

正在加载...
取消
保存