📄 uimanager.java
字号:
Boolean value = (Boolean) get(key); return value != null ? value.booleanValue() : false; } /** * Returns a boolean value from the defaults table, * <code>false</code> if key is not present. * * @since 1.4 */ public static boolean getBoolean(Object key, Locale locale) { Boolean value = (Boolean) get(key, locale); return value != null ? value.booleanValue() : false; } /** * Returns a border from the defaults table. */ public static Border getBorder(Object key) { return (Border) get(key); } /** * Returns a border from the defaults table. * * @since 1.4 */ public static Border getBorder(Object key, Locale locale) { return (Border) get(key, locale); } /** * Returns a drawing color from the defaults table. */ public static Color getColor(Object key) { return (Color) get(key); } /** * Returns a drawing color from the defaults table. */ public static Color getColor(Object key, Locale locale) { return (Color) get(key); } /** * The fully qualified class name of the cross platform (Metal) look and feel. * This string can be passed to Class.forName() * * @return <code>"javax.swing.plaf.metal.MetalLookAndFeel"</code> */ public static String getCrossPlatformLookAndFeelClassName() { return "javax.swing.plaf.metal.MetalLookAndFeel"; } /** * Returns the default values for this look and feel. * * @return The {@link UIDefaults} for the current {@link LookAndFeel}. */ public static UIDefaults getDefaults() { return currentUIDefaults; } /** * Returns a dimension from the defaults table. */ public static Dimension getDimension(Object key) { return (Dimension) get(key); } /** * Returns a dimension from the defaults table. */ public static Dimension getDimension(Object key, Locale locale) { return (Dimension) get(key, locale); } /** * Retrieves a font from the defaults table of the current * LookAndFeel. * * @param key an Object that specifies the font. Typically, * this is a String such as * <code>TitledBorder.font</code>. */ public static Font getFont(Object key) { return (Font) get(key); } /** * Retrieves a font from the defaults table of the current * LookAndFeel. * * @param key an Object that specifies the font. Typically, * this is a String such as * <code>TitledBorder.font</code>. */ public static Font getFont(Object key, Locale locale) { return (Font) get(key ,locale); } /** * Returns an Icon from the defaults table. */ public static Icon getIcon(Object key) { return (Icon) get(key); } /** * Returns an Icon from the defaults table. */ public static Icon getIcon(Object key, Locale locale) { return (Icon) get(key, locale); } /** * Returns an Insets object from the defaults table. */ public static Insets getInsets(Object key) { Object o = get(key); if (o instanceof Insets) return (Insets) o; else return null; } /** * Returns an Insets object from the defaults table. */ public static Insets getInsets(Object key, Locale locale) { Object o = get(key, locale); if (o instanceof Insets) return (Insets) o; else return null; } /** * Returns an array containing information about the {@link LookAndFeel}s * that are installed. * * @return A list of the look and feels that are available (installed). */ public static LookAndFeelInfo[] getInstalledLookAndFeels() { return installed; } public static int getInt(Object key) { Integer x = (Integer) get(key); if (x == null) return 0; return x.intValue(); } public static int getInt(Object key, Locale locale) { Integer x = (Integer) get(key, locale); if (x == null) return 0; return x.intValue(); } /** * Returns the current look and feel (which may be <code>null</code>). * * @return The current look and feel. * * @see #setLookAndFeel(LookAndFeel) */ public static LookAndFeel getLookAndFeel() { return currentLookAndFeel; } /** * Returns the <code>UIDefaults</code> table of the currently active * look and feel. * * @return The {@link UIDefaults} for the current {@link LookAndFeel}. */ public static UIDefaults getLookAndFeelDefaults() { return currentUIDefaults; } /** * Returns a string from the defaults table. */ public static String getString(Object key) { return (String) get(key); } /** * Returns a string from the defaults table. */ public static String getString(Object key, Locale locale) { return (String) get(key, locale); } /** * Returns the name of the {@link LookAndFeel} class that implements the * native systems look and feel if there is one, otherwise the name * of the default cross platform LookAndFeel class. * * @return The fully qualified class name for the system look and feel. * * @see #getCrossPlatformLookAndFeelClassName() */ public static String getSystemLookAndFeelClassName() { return getCrossPlatformLookAndFeelClassName(); } /** * Returns UI delegate from the current {@link LookAndFeel} that renders the * target component. * * @param target the target component. */ public static ComponentUI getUI(JComponent target) { ComponentUI ui = null; if (userUIDefaults != null && userUIDefaults.get(target.getUIClassID()) != null) ui = userUIDefaults.getUI(target); if (ui == null) ui = currentUIDefaults.getUI(target); return ui; } /** * Creates a new look and feel and adds it to the current array. * * @param name the look and feel name. * @param className the fully qualified name of the class that implements the * look and feel. */ public static void installLookAndFeel(String name, String className) { installLookAndFeel(new LookAndFeelInfo(name, className)); } /** * Adds the specified look and feel to the current array and then calls * setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[]). */ public static void installLookAndFeel(LookAndFeelInfo info) { // FIXME: not yet implemented } /** * Stores an object in the defaults table. */ public static Object put(Object key, Object value) { Object old = get(key); if (userUIDefaults == null) userUIDefaults = new UIDefaults(); userUIDefaults.put(key, value); return old; } /** * Replaces the current array of installed LookAndFeelInfos. */ public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos) { // FIXME: not yet implemented. } /** * Sets the current {@link LookAndFeel}. * * @param newLookAndFeel the new look and feel (<code>null</code> permitted). * * @throws UnsupportedLookAndFeelException if the look and feel is not * supported on the current platform. * * @see LookAndFeel#isSupportedLookAndFeel() */ public static void setLookAndFeel(LookAndFeel newLookAndFeel) throws UnsupportedLookAndFeelException { if (newLookAndFeel != null && ! newLookAndFeel.isSupportedLookAndFeel()) throw new UnsupportedLookAndFeelException(newLookAndFeel.getName()); LookAndFeel oldLookAndFeel = currentLookAndFeel; if (oldLookAndFeel != null) oldLookAndFeel.uninitialize(); // Set the current default look and feel using a LookAndFeel object. currentLookAndFeel = newLookAndFeel; if (newLookAndFeel != null) { newLookAndFeel.initialize(); currentUIDefaults = newLookAndFeel.getDefaults(); } else { currentUIDefaults = null; } listeners.firePropertyChange("lookAndFeel", oldLookAndFeel, newLookAndFeel); //revalidate(); //repaint(); } /** * Set the current default look and feel using a class name. * * @param className the look and feel class name. * * @throws UnsupportedLookAndFeelException if the look and feel is not * supported on the current platform. * * @see LookAndFeel#isSupportedLookAndFeel() */ public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { Class c = Class.forName(className); LookAndFeel a = (LookAndFeel) c.newInstance(); // throws class-cast-exception setLookAndFeel(a); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -