File: MacUtils.java

package info (click to toggle)
mac-widgets 0.10.0%2Bsvn416-dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,968 kB
  • ctags: 2,003
  • sloc: java: 9,909; makefile: 13; sh: 12
file content (39 lines) | stat: -rw-r--r-- 1,427 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.explodingpixels.macwidgets;

import javax.swing.JRootPane;

import com.explodingpixels.util.PlatformUtils;

/**
 * A collection of utilities related to the Mac.
 */
public class MacUtils {

    /**
     * Makes this window a Unified window on Mac OS X Leopard or greater systems.
     *
     * @param rootPane
     */
    public static void makeWindowLeopardStyle(JRootPane rootPane) {
        // TODO figure out correct way to determine if the JRootPane has been
        // TODO realized.
        if (rootPane.isValid()) {
            throw new IllegalArgumentException("This method only works if the" +
                    "given JRootPane has not yet been realized.");
        }

        rootPane.putClientProperty("apple.awt.brushMetalLook", Boolean.TRUE);
    }

    /**
     * {@code true} if the Unified Tool Bar, Preference Tool Bar or Bottom Bar backgrounds should
     * be manually painted in code, rather than letting Mac OS X do the painting. This will always
     * return true on platforms other than Mac, and will sometimes return true on Mac's due to
     * painting bugs in the Java distrobution.
     */
    public static boolean shouldManuallyPaintTexturedWindowBackground() {
        boolean shouldManuallyPaintOnMac =
                PlatformUtils.isMac() && PlatformUtils.isLeopard() && PlatformUtils.isJava6OnMac();
        return !PlatformUtils.isMac() || shouldManuallyPaintOnMac;
    }
}