Java Code Examples for java.awt.Toolkit#getDesktopProperty()

The following examples show how to use java.awt.Toolkit#getDesktopProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Win32ShellFolder2.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets an icon from the Windows system icon list as an <code>Image</code>
 */
static Image getShell32Icon(int iconID, boolean getLargeIcon) {
    boolean useVGAColors = true; // Will be ignored on XP and later

    int size = getLargeIcon ? 32 : 16;

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    String shellIconBPP = (String)toolkit.getDesktopProperty("win.icon.shellIconBPP");
    if (shellIconBPP != null) {
        useVGAColors = shellIconBPP.equals("4");
    }

    long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
    if (hIcon != 0) {
        Image icon = makeIcon(hIcon, getLargeIcon);
        disposeIcon(hIcon);
        return icon;
    }
    return null;
}
 
Example 2
Source File: Win32ShellFolder2.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets an icon from the Windows system icon list as an <code>Image</code>
 */
static Image getShell32Icon(int iconID, boolean getLargeIcon) {
    boolean useVGAColors = true; // Will be ignored on XP and later

    int size = getLargeIcon ? 32 : 16;

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    String shellIconBPP = (String)toolkit.getDesktopProperty("win.icon.shellIconBPP");
    if (shellIconBPP != null) {
        useVGAColors = shellIconBPP.equals("4");
    }

    long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
    if (hIcon != 0) {
        Image icon = makeIcon(hIcon, getLargeIcon);
        disposeIcon(hIcon);
        return icon;
    }
    return null;
}
 
Example 3
Source File: Win32ShellFolder2.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets an icon from the Windows system icon list as an {@code Image}
 */
static Image getShell32Icon(int iconID, boolean getLargeIcon) {
    boolean useVGAColors = true; // Will be ignored on XP and later

    int size = getLargeIcon ? 32 : 16;

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    String shellIconBPP = (String)toolkit.getDesktopProperty("win.icon.shellIconBPP");
    if (shellIconBPP != null) {
        useVGAColors = shellIconBPP.equals("4");
    }

    long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
    if (hIcon != 0) {
        Image icon = makeIcon(hIcon, getLargeIcon);
        disposeIcon(hIcon);
        return icon;
    }
    return null;
}
 
Example 4
Source File: SwingUtilities2.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static void putAATextInfo(boolean lafCondition,
        Map<Object, Object> map) {
    SunToolkit.setAAFontSettingsCondition(lafCondition);
    Toolkit tk = Toolkit.getDefaultToolkit();
    Object desktopHints = tk.getDesktopProperty(SunToolkit.DESKTOPFONTHINTS);

    if (desktopHints instanceof Map) {
        Map<Object, Object> hints = (Map<Object, Object>) desktopHints;
        Object aaHint = hints.get(KEY_TEXT_ANTIALIASING);
        if (aaHint == null
                || aaHint == VALUE_TEXT_ANTIALIAS_OFF
                || aaHint == VALUE_TEXT_ANTIALIAS_DEFAULT) {
            return;
        }
        map.put(KEY_TEXT_ANTIALIASING, aaHint);
        map.put(KEY_TEXT_LCD_CONTRAST, hints.get(KEY_TEXT_LCD_CONTRAST));
    }
}
 
Example 5
Source File: Win32ShellFolder2.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets an icon from the Windows system icon list as an <code>Image</code>
 */
static Image getShell32Icon(int iconID, boolean getLargeIcon) {
    boolean useVGAColors = true; // Will be ignored on XP and later

    int size = getLargeIcon ? 32 : 16;

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    String shellIconBPP = (String)toolkit.getDesktopProperty("win.icon.shellIconBPP");
    if (shellIconBPP != null) {
        useVGAColors = shellIconBPP.equals("4");
    }

    long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
    if (hIcon != 0) {
        Image icon = makeIcon(hIcon, getLargeIcon);
        disposeIcon(hIcon);
        return icon;
    }
    return null;
}
 
Example 6
Source File: Win32ShellFolder2.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets an icon from the Windows system icon list as an <code>Image</code>
 */
static Image getShell32Icon(int iconID, boolean getLargeIcon) {
    boolean useVGAColors = true; // Will be ignored on XP and later

    int size = getLargeIcon ? 32 : 16;

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    String shellIconBPP = (String)toolkit.getDesktopProperty("win.icon.shellIconBPP");
    if (shellIconBPP != null) {
        useVGAColors = shellIconBPP.equals("4");
    }

    long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
    if (hIcon != 0) {
        Image icon = makeIcon(hIcon, getLargeIcon);
        disposeIcon(hIcon);
        return icon;
    }
    return null;
}
 
Example 7
Source File: Win32ShellFolder2.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets an icon from the Windows system icon list as an <code>Image</code>
 */
static Image getShell32Icon(int iconID, boolean getLargeIcon) {
    boolean useVGAColors = true; // Will be ignored on XP and later

    int size = getLargeIcon ? 32 : 16;

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    String shellIconBPP = (String)toolkit.getDesktopProperty("win.icon.shellIconBPP");
    if (shellIconBPP != null) {
        useVGAColors = shellIconBPP.equals("4");
    }

    long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
    if (hIcon != 0) {
        Image icon = makeIcon(hIcon, getLargeIcon);
        disposeIcon(hIcon);
        return icon;
    }
    return null;
}
 
Example 8
Source File: Win32ShellFolder2.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets an icon from the Windows system icon list as an <code>Image</code>
 */
static Image getShell32Icon(int iconID, boolean getLargeIcon) {
    boolean useVGAColors = true; // Will be ignored on XP and later

    int size = getLargeIcon ? 32 : 16;

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    String shellIconBPP = (String)toolkit.getDesktopProperty("win.icon.shellIconBPP");
    if (shellIconBPP != null) {
        useVGAColors = shellIconBPP.equals("4");
    }

    long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
    if (hIcon != 0) {
        Image icon = makeIcon(hIcon, getLargeIcon);
        disposeIcon(hIcon);
        return icon;
    }
    return null;
}
 
Example 9
Source File: Win32ShellFolder2.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets an icon from the Windows system icon list as an <code>Image</code>
 */
static Image getShell32Icon(int iconID, boolean getLargeIcon) {
    boolean useVGAColors = true; // Will be ignored on XP and later

    int size = getLargeIcon ? 32 : 16;

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    String shellIconBPP = (String)toolkit.getDesktopProperty("win.icon.shellIconBPP");
    if (shellIconBPP != null) {
        useVGAColors = shellIconBPP.equals("4");
    }

    long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
    if (hIcon != 0) {
        Image icon = makeIcon(hIcon, getLargeIcon);
        disposeIcon(hIcon);
        return icon;
    }
    return null;
}
 
Example 10
Source File: Win32ShellFolder2.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets an icon from the Windows system icon list as an <code>Image</code>
 */
static Image getShell32Icon(int iconID, boolean getLargeIcon) {
    boolean useVGAColors = true; // Will be ignored on XP and later

    int size = getLargeIcon ? 32 : 16;

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    String shellIconBPP = (String)toolkit.getDesktopProperty("win.icon.shellIconBPP");
    if (shellIconBPP != null) {
        useVGAColors = shellIconBPP.equals("4");
    }

    long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
    if (hIcon != 0) {
        Image icon = makeIcon(hIcon, getLargeIcon);
        disposeIcon(hIcon);
        return icon;
    }
    return null;
}
 
Example 11
Source File: JFileChooser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void installShowFilesListener() {
    // Track native setting for showing hidden files
    Toolkit tk = Toolkit.getDefaultToolkit();
    Object showHiddenProperty = tk.getDesktopProperty(SHOW_HIDDEN_PROP);
    if (showHiddenProperty instanceof Boolean) {
        useFileHiding = !((Boolean)showHiddenProperty).booleanValue();
        showFilesListener = new WeakPCL(this);
        tk.addPropertyChangeListener(SHOW_HIDDEN_PROP, showFilesListener);
    }
}
 
Example 12
Source File: JFileChooser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void installShowFilesListener() {
    // Track native setting for showing hidden files
    Toolkit tk = Toolkit.getDefaultToolkit();
    Object showHiddenProperty = tk.getDesktopProperty(SHOW_HIDDEN_PROP);
    if (showHiddenProperty instanceof Boolean) {
        useFileHiding = !((Boolean)showHiddenProperty).booleanValue();
        showFilesListener = new WeakPCL(this);
        tk.addPropertyChangeListener(SHOW_HIDDEN_PROP, showFilesListener);
    }
}
 
Example 13
Source File: JFileChooser.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private void installShowFilesListener() {
    // Track native setting for showing hidden files
    Toolkit tk = Toolkit.getDefaultToolkit();
    Object showHiddenProperty = tk.getDesktopProperty(SHOW_HIDDEN_PROP);
    if (showHiddenProperty instanceof Boolean) {
        useFileHiding = !((Boolean)showHiddenProperty).booleanValue();
        showFilesListener = new WeakPCL(this);
        tk.addPropertyChangeListener(SHOW_HIDDEN_PROP, showFilesListener);
    }
}
 
Example 14
Source File: JFileChooser.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private void installShowFilesListener() {
    // Track native setting for showing hidden files
    Toolkit tk = Toolkit.getDefaultToolkit();
    Object showHiddenProperty = tk.getDesktopProperty(SHOW_HIDDEN_PROP);
    if (showHiddenProperty instanceof Boolean) {
        useFileHiding = !((Boolean)showHiddenProperty).booleanValue();
        showFilesListener = new WeakPCL(this);
        tk.addPropertyChangeListener(SHOW_HIDDEN_PROP, showFilesListener);
    }
}
 
Example 15
Source File: DesktopProperty.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value from the desktop.
 */
protected Object getValueFromDesktop() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();

    if (pcl == null) {
        pcl = new WeakPCL(this, getKey(), UIManager.getLookAndFeel());
        toolkit.addPropertyChangeListener(getKey(), pcl);
    }

    return toolkit.getDesktopProperty(getKey());
}
 
Example 16
Source File: JFileChooser.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private void installShowFilesListener() {
    // Track native setting for showing hidden files
    Toolkit tk = Toolkit.getDefaultToolkit();
    Object showHiddenProperty = tk.getDesktopProperty(SHOW_HIDDEN_PROP);
    if (showHiddenProperty instanceof Boolean) {
        useFileHiding = !((Boolean)showHiddenProperty).booleanValue();
        showFilesListener = new WeakPCL(this);
        tk.addPropertyChangeListener(SHOW_HIDDEN_PROP, showFilesListener);
    }
}
 
Example 17
Source File: JFileChooser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void installShowFilesListener() {
    // Track native setting for showing hidden files
    Toolkit tk = Toolkit.getDefaultToolkit();
    Object showHiddenProperty = tk.getDesktopProperty(SHOW_HIDDEN_PROP);
    if (showHiddenProperty instanceof Boolean) {
        useFileHiding = !((Boolean)showHiddenProperty).booleanValue();
        showFilesListener = new WeakPCL(this);
        tk.addPropertyChangeListener(SHOW_HIDDEN_PROP, showFilesListener);
    }
}
 
Example 18
Source File: JFileChooser.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void installShowFilesListener() {
    // Track native setting for showing hidden files
    Toolkit tk = Toolkit.getDefaultToolkit();
    Object showHiddenProperty = tk.getDesktopProperty(SHOW_HIDDEN_PROP);
    if (showHiddenProperty instanceof Boolean) {
        useFileHiding = !((Boolean)showHiddenProperty).booleanValue();
        showFilesListener = new WeakPCL(this);
        tk.addPropertyChangeListener(SHOW_HIDDEN_PROP, showFilesListener);
    }
}
 
Example 19
Source File: JFileChooser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void installShowFilesListener() {
    // Track native setting for showing hidden files
    Toolkit tk = Toolkit.getDefaultToolkit();
    Object showHiddenProperty = tk.getDesktopProperty(SHOW_HIDDEN_PROP);
    if (showHiddenProperty instanceof Boolean) {
        useFileHiding = !((Boolean)showHiddenProperty).booleanValue();
        showFilesListener = new WeakPCL(this);
        tk.addPropertyChangeListener(SHOW_HIDDEN_PROP, showFilesListener);
    }
}
 
Example 20
Source File: JBRCustomDecorations.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
private Color calculateActiveBorderColor() {
	if( !colorizationAffectsBorders )
		return defaultActiveBorder;

	Toolkit toolkit = Toolkit.getDefaultToolkit();
	Color colorizationColor = (Color) toolkit.getDesktopProperty( "win.dwm.colorizationColor" );
	if( colorizationColor != null ) {
		Object colorizationColorBalanceObj = toolkit.getDesktopProperty( "win.dwm.colorizationColorBalance" );
		if( colorizationColorBalanceObj instanceof Integer ) {
			int colorizationColorBalance = (Integer) colorizationColorBalanceObj;
			if( colorizationColorBalance < 0 )
				colorizationColorBalance = 100;

			if( colorizationColorBalance == 0 )
				return new Color( 0xD9D9D9 );
			if( colorizationColorBalance == 100 )
				return colorizationColor;

			float alpha = colorizationColorBalance / 100.0f;
			float remainder = 1 - alpha;
			int r = Math.round( (colorizationColor.getRed() * alpha + 0xD9 * remainder) );
			int g = Math.round( (colorizationColor.getGreen() * alpha + 0xD9 * remainder) );
			int b = Math.round( (colorizationColor.getBlue() * alpha + 0xD9 * remainder) );
			return new Color( r, g, b );
		}
		return colorizationColor;
	}

	Color activeBorderColor = (Color) toolkit.getDesktopProperty( "win.frame.activeBorderColor" );
	return (activeBorderColor != null) ? activeBorderColor : UIManager.getColor( "MenuBar.borderColor" );
}