Java Code Examples for javax.swing.UIDefaults#LazyValue

The following examples show how to use javax.swing.UIDefaults#LazyValue . 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: SwingUtilities2.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private static Object makeIcon(final Class<?> baseClass,
                              final Class<?> rootClass,
                              final String imageFile,
                              final boolean enablePrivileges) {
    return (UIDefaults.LazyValue) (table) -> {
        byte[] buffer = enablePrivileges ? AccessController.doPrivileged(
                (PrivilegedAction<byte[]>) ()
                -> getIconBytes(baseClass, rootClass, imageFile))
                : getIconBytes(baseClass, rootClass, imageFile);

        if (buffer == null) {
            return null;
        }
        if (buffer.length == 0) {
            System.err.println("warning: " + imageFile
                    + " is zero-length");
            return null;
        }

        return new ImageIconUIResource(buffer);
    };
}
 
Example 2
Source File: DesktopProperty.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Configures the value as appropriate for a defaults property in
 * the UIDefaults table.
 */
protected Object configureValue(Object value) {
    if (value != null) {
        if (value instanceof Color) {
            return new ColorUIResource((Color)value);
        }
        else if (value instanceof Font) {
            return new FontUIResource((Font)value);
        }
        else if (value instanceof UIDefaults.LazyValue) {
            value = ((UIDefaults.LazyValue)value).createValue(null);
        }
        else if (value instanceof UIDefaults.ActiveValue) {
            value = ((UIDefaults.ActiveValue)value).createValue(null);
        }
    }
    return value;
}
 
Example 3
Source File: NimbusStyle.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private Painter<Object> getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    @SuppressWarnings("unchecked")
    Painter<Object> tmp = (p instanceof Painter ? (Painter)p : null);
    return tmp;
}
 
Example 4
Source File: SeaGlassStyle.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Determine the painter given the defaults and a key.
 *
 * @param  defaults the defaults.
 * @param  key      the key.
 *
 * @return the painter, if any can be found, {@code null} otherwise.
 */
private SeaGlassPainter getPainter(TreeMap<String, Object> defaults, String key) {
    Object p = defaults.get(key);

    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue) p).createValue(UIManager.getDefaults());
    }

    return (p instanceof SeaGlassPainter ? (SeaGlassPainter) p : null);
}
 
Example 5
Source File: NimbusStyle.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 6
Source File: NimbusStyle.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 7
Source File: NimbusStyle.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 8
Source File: NimbusStyle.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 9
Source File: NimbusStyle.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 10
Source File: NimbusStyle.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 11
Source File: NimbusStyle.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 12
Source File: NimbusStyle.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private Painter<Object> getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    @SuppressWarnings("unchecked")
    Painter<Object> tmp = (p instanceof Painter ? (Painter)p : null);
    return tmp;
}
 
Example 13
Source File: NimbusStyle.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 14
Source File: NimbusStyle.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 15
Source File: NimbusStyle.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 16
Source File: NimbusStyle.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 17
Source File: NimbusStyle.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 18
Source File: NimbusStyle.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 19
Source File: NimbusStyle.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example 20
Source File: NimbusLFCustoms.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
    public Object[] createApplicationSpecificKeysAndValues () {
        /*Border outerBorder = BorderFactory.createLineBorder(UIManager.getColor("controlShadow")); //NOI18N
        Object propertySheetColorings = new MetalPropertySheetColorings();
        Color unfocusedSelBg = UIManager.getColor("controlShadow");
        if (!Color.WHITE.equals(unfocusedSelBg.brighter())) { // #57145
            unfocusedSelBg = unfocusedSelBg.brighter();
        }*/

        Object[] result = {
            EDITOR_PREFERRED_COLOR_PROFILE, "NetBeans", //NOI18N
            //UI Delegates for the tab control
            EDITOR_TAB_DISPLAYER_UI,
                "org.netbeans.swing.tabcontrol.plaf.NimbusEditorTabDisplayerUI", //NOI18N
            VIEW_TAB_DISPLAYER_UI,
                "org.netbeans.swing.tabcontrol.plaf.NimbusViewTabDisplayerUI", //NOI18N
            SLIDING_TAB_BUTTON_UI, "org.netbeans.swing.tabcontrol.plaf.SlidingTabDisplayerButtonUI", //NOI18N
            SLIDING_BUTTON_UI, "org.netbeans.swing.tabcontrol.plaf.NimbusSlidingButtonUI", //NOI18N
            SCROLLPANE_BORDER, new UIDefaults.LazyValue() {
                @Override
                public Object createValue(UIDefaults table) {
                    return new JScrollPane().getViewportBorder();
                }
            }, 
            //Borders for the tab control
            EDITOR_TAB_OUTER_BORDER, BorderFactory.createEmptyBorder(),
            EDITOR_TAB_CONTENT_BORDER,
                new MatteBorder(0, 1, 1, 1, UIManager.getColor("nimbusBorder")), //NOI18N
            EDITOR_TAB_TABS_BORDER, BorderFactory.createEmptyBorder(),

            VIEW_TAB_OUTER_BORDER, BorderFactory.createEmptyBorder(),
            VIEW_TAB_CONTENT_BORDER,
                new MatteBorder(0, 1, 1, 1, UIManager.getColor("nimbusBorder")), //NOI18N
            VIEW_TAB_TABS_BORDER, BorderFactory.createEmptyBorder(),
            //slide bar
            "NbSlideBar.GroupSeparator.Gap.Before", 12,
            "NbSlideBar.GroupSeparator.Gap.After", 4,
            "NbSlideBar.RestoreButton.Gap", 8,
            //#212453
            "Nb.EmptyEditorArea.border", BorderFactory.createEtchedBorder( EtchedBorder.LOWERED ),

            //browser picker
            "Nb.browser.picker.background.light", new Color(249,249,249),
            "Nb.browser.picker.foreground.light", new Color(130,130,130),
        };
        /*Object[] result = {
            DESKTOP_BORDER, new EmptyBorder(1, 1, 1, 1),
            SCROLLPANE_BORDER, new NimbusScrollPaneBorder(),
            EXPLORER_STATUS_BORDER, new StatusLineBorder(StatusLineBorder.TOP),
            EDITOR_STATUS_LEFT_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.RIGHT),
            EDITOR_STATUS_RIGHT_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT),
            EDITOR_STATUS_INNER_BORDER, new StatusLineBorder(StatusLineBorder.TOP | StatusLineBorder.LEFT | StatusLineBorder.RIGHT),
            EDITOR_STATUS_ONLYONEBORDER, new StatusLineBorder(StatusLineBorder.TOP),
            EDITOR_TOOLBAR_BORDER, new EditorToolbarBorder(),

            PROPERTYSHEET_BOOTSTRAP, propertySheetColorings,

            //UI Delegates for the tab control
            EDITOR_TAB_DISPLAYER_UI, "org.netbeans.swing.tabcontrol.plaf.MetalEditorTabDisplayerUI",
            VIEW_TAB_DISPLAYER_UI, "org.netbeans.swing.tabcontrol.plaf.MetalViewTabDisplayerUI",
            SLIDING_BUTTON_UI, "org.netbeans.swing.tabcontrol.plaf.MetalSlidingButtonUI",

            EDITOR_TAB_OUTER_BORDER, outerBorder,
            VIEW_TAB_OUTER_BORDER, outerBorder,

            EXPLORER_MINISTATUSBAR_BORDER, BorderFactory.createMatteBorder(1, 0, 0, 0, UIManager.getColor("controlShadow")),

            //#48951 invisible unfocused selection background in Metal L&F
            "nb.explorer.unfocusedSelBg", unfocusedSelBg,

            PROGRESS_CANCEL_BUTTON_ICON, UIUtils.loadImage("org/netbeans/swing/plaf/resources/cancel_task_win_linux_mac.png"),


            // progress component related
//            "nbProgressBar.Foreground", new Color(49, 106, 197),
//            "nbProgressBar.Background", Color.WHITE,
            "nbProgressBar.popupDynaText.foreground", new Color(115, 115, 115),
//            "nbProgressBar.popupText.background", new Color(231, 249, 249),
            "nbProgressBar.popupText.foreground", UIManager.getColor("TextField.foreground"),
            "nbProgressBar.popupText.selectBackground", UIManager.getColor("List.selectionBackground"),
            "nbProgressBar.popupText.selectForeground", UIManager.getColor("List.selectionForeground"),

        };*/

        //#108517 - turn off ctrl+page_up and ctrl+page_down mapping
        return UIUtils.addInputMapsWithoutCtrlPageUpAndCtrlPageDown( result );
    }