javax.swing.UIDefaults Java Examples
The following examples show how to use
javax.swing.UIDefaults.
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: NimbusLookAndFeel.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Creates the value retrieved from the <code>UIDefaults</code> table. * The object is created each time it is accessed. * * @param table a <code>UIDefaults</code> table * @return the created <code>Object</code> */ @Override public Object createValue(UIDefaults table) { Object obj = null; // check specified state if (state!=null){ obj = uiDefaults.get(prefix+"["+state+"]."+suffix); } // check enabled state if (obj==null){ obj = uiDefaults.get(prefix+"[Enabled]."+suffix); } // check for defaults if (obj==null){ if (isFont) { obj = uiDefaults.get("defaultFont"); } else { obj = uiDefaults.get(suffix); } } return obj; }
Example #2
Source File: NimbusLookAndFeel.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Creates the value retrieved from the <code>UIDefaults</code> table. * The object is created each time it is accessed. * * @param table a <code>UIDefaults</code> table * @return the created <code>Object</code> */ @Override public Object createValue(UIDefaults table) { Object obj = null; // check specified state if (state!=null){ obj = uiDefaults.get(prefix+"["+state+"]."+suffix); } // check enabled state if (obj==null){ obj = uiDefaults.get(prefix+"[Enabled]."+suffix); } // check for defaults if (obj==null){ if (isFont) { obj = uiDefaults.get("defaultFont"); } else { obj = uiDefaults.get(suffix); } } return obj; }
Example #3
Source File: XTextAreaPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override protected void installKeyboardActions() { super.installKeyboardActions(); JTextComponent comp = getComponent(); UIDefaults uidefaults = XToolkit.getUIDefaults(); String prefix = getPropertyPrefix(); InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap"); if (map != null) { SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED, map); } }
Example #4
Source File: WrongBackgroundColor.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws InvocationTargetException, InterruptedException { SwingUtilities.invokeAndWait(() -> { UIDefaults ui = UIManager.getDefaults(); ui.put("control", new ColorUIResource(54, 54, 54)); final JDialog dialog = new JDialog(); final JFrame frame = new JFrame(); frame.pack(); dialog.pack(); final Color dialogBackground = dialog.getBackground(); final Color frameBackground = frame.getBackground(); frame.dispose(); dialog.dispose(); if (!dialogBackground.equals(frameBackground)) { System.err.println("Expected:" + frameBackground); System.err.println("Actual:" + dialogBackground); throw new RuntimeException("Wrong background color"); } }); }
Example #5
Source File: NimbusLookAndFeel.java From Java8CN with Apache License 2.0 | 6 votes |
/** * Creates the value retrieved from the <code>UIDefaults</code> table. * The object is created each time it is accessed. * * @param table a <code>UIDefaults</code> table * @return the created <code>Object</code> */ @Override public Object createValue(UIDefaults table) { Object obj = null; // check specified state if (state!=null){ obj = uiDefaults.get(prefix+"["+state+"]."+suffix); } // check enabled state if (obj==null){ obj = uiDefaults.get(prefix+"[Enabled]."+suffix); } // check for defaults if (obj==null){ if (isFont) { obj = uiDefaults.get("defaultFont"); } else { obj = uiDefaults.get(suffix); } } return obj; }
Example #6
Source File: Test8039750.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) { UIDefaults table= new MetalLookAndFeel().getDefaults(); test(table.get("ToolBar.rolloverBorder"), "javax.swing.plaf.metal.MetalBorders$ButtonBorder", "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder"); test(table.get("ToolBar.nonrolloverBorder"), "javax.swing.plaf.metal.MetalBorders$ButtonBorder", "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder"); test(table.get("RootPane.frameBorder"), "javax.swing.plaf.metal.MetalBorders$FrameBorder"); test(table.get("RootPane.plainDialogBorder"), "javax.swing.plaf.metal.MetalBorders$DialogBorder"); test(table.get("RootPane.informationDialogBorder"), "javax.swing.plaf.metal.MetalBorders$DialogBorder"); test(table.get("RootPane.errorDialogBorder"), "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder"); test(table.get("RootPane.colorChooserDialogBorder"), "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder"); test(table.get("RootPane.fileChooserDialogBorder"), "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder"); test(table.get("RootPane.questionDialogBorder"), "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder"); test(table.get("RootPane.warningDialogBorder"), "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder"); }
Example #7
Source File: ContrastMetalTheme.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void addCustomEntriesToTable(UIDefaults table) { Border blackLineBorder = new BorderUIResource(new LineBorder(getBlack())); Border whiteLineBorder = new BorderUIResource(new LineBorder(getWhite())); Object textBorder = new BorderUIResource(new CompoundBorder( blackLineBorder, new BasicBorders.MarginBorder())); table.put("ToolTip.border", blackLineBorder); table.put("TitledBorder.border", blackLineBorder); table.put("Table.focusCellHighlightBorder", whiteLineBorder); table.put("Table.focusCellForeground", getWhite()); table.put("TextField.border", textBorder); table.put("PasswordField.border", textBorder); table.put("TextArea.border", textBorder); table.put("TextPane.font", textBorder); }
Example #8
Source File: NimbusLookAndFeel.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Creates the value retrieved from the <code>UIDefaults</code> table. * The object is created each time it is accessed. * * @param table a <code>UIDefaults</code> table * @return the created <code>Object</code> */ @Override public Object createValue(UIDefaults table) { Object obj = null; // check specified state if (state!=null){ obj = uiDefaults.get(prefix+"["+state+"]."+suffix); } // check enabled state if (obj==null){ obj = uiDefaults.get(prefix+"[Enabled]."+suffix); } // check for defaults if (obj==null){ if (isFont) { obj = uiDefaults.get("defaultFont"); } else { obj = uiDefaults.get(suffix); } } return obj; }
Example #9
Source File: XTextFieldPeer.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override protected void installKeyboardActions() { super.installKeyboardActions(); JTextComponent comp = getComponent(); UIDefaults uidefaults = XToolkit.getUIDefaults(); String prefix = getPropertyPrefix(); InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap"); if (map != null) { SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED, map); } }
Example #10
Source File: XTextAreaPeer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override protected void installKeyboardActions() { super.installKeyboardActions(); JTextComponent comp = getComponent(); UIDefaults uidefaults = XToolkit.getUIDefaults(); String prefix = getPropertyPrefix(); InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap"); if (map != null) { SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED, map); } }
Example #11
Source File: ContrastMetalTheme.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public void addCustomEntriesToTable(UIDefaults table) { Border blackLineBorder = new BorderUIResource(new LineBorder(getBlack())); Border whiteLineBorder = new BorderUIResource(new LineBorder(getWhite())); Object textBorder = new BorderUIResource(new CompoundBorder( blackLineBorder, new BasicBorders.MarginBorder())); table.put("ToolTip.border", blackLineBorder); table.put("TitledBorder.border", blackLineBorder); table.put("Table.focusCellHighlightBorder", whiteLineBorder); table.put("Table.focusCellForeground", getWhite()); table.put("TextField.border", textBorder); table.put("PasswordField.border", textBorder); table.put("TextArea.border", textBorder); table.put("TextPane.font", textBorder); }
Example #12
Source File: XTextAreaPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override protected void installKeyboardActions() { super.installKeyboardActions(); JTextComponent comp = getComponent(); UIDefaults uidefaults = XToolkit.getUIDefaults(); String prefix = getPropertyPrefix(); InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap"); if (map != null) { SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED, map); } }
Example #13
Source File: DemoMetalTheme.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public void addCustomEntriesToTable(UIDefaults table) { super.addCustomEntriesToTable(table); final int internalFrameIconSize = 22; table.put("InternalFrame.closeIcon", MetalIconFactory. getInternalFrameCloseIcon(internalFrameIconSize)); table.put("InternalFrame.maximizeIcon", MetalIconFactory. getInternalFrameMaximizeIcon(internalFrameIconSize)); table.put("InternalFrame.iconifyIcon", MetalIconFactory. getInternalFrameMinimizeIcon(internalFrameIconSize)); table.put("InternalFrame.minimizeIcon", MetalIconFactory. getInternalFrameAltMaximizeIcon(internalFrameIconSize)); table.put("ScrollBar.width", 21); }
Example #14
Source File: IntelliJTheme.java From FlatLaf with Apache License 2.0 | 6 votes |
/** * http://www.jetbrains.org/intellij/sdk/docs/reference_guide/ui_themes/themes_customize.html#defining-named-colors */ private void loadNamedColors( UIDefaults defaults ) { if( colors == null ) return; namedColors = new HashMap<>(); for( Map.Entry<String, String> e : colors.entrySet() ) { String value = e.getValue(); ColorUIResource color = UIDefaultsLoader.parseColor( value ); if( color != null ) { String key = e.getKey(); namedColors.put( key, color ); defaults.put( "ColorPalette." + key, color ); } } }
Example #15
Source File: SeaGlassLookAndFeel.java From seaglass with Apache License 2.0 | 6 votes |
/** * Use Aqua settings for some properties if we're on a Mac. * * @param d the UI defaults map. */ private void defineAquaSettings(UIDefaults d) { try { // Instantiate Aqua but don't install it. Class<?> lnfClass = Class.forName(UIManager.getSystemLookAndFeelClassName(), true, Thread.currentThread().getContextClassLoader()); LookAndFeel aqua = (LookAndFeel) lnfClass.newInstance(); UIDefaults aquaDefaults = aqua.getDefaults(); // Use Aqua for any menu UI classes. d.put("MenuBarUI", aquaDefaults.get("MenuBarUI")); d.put("MenuUI", aquaDefaults.get("MenuUI")); } catch (Exception e) { // TODO Should we do something with this exception? e.printStackTrace(); } }
Example #16
Source File: RapidLookAndFeel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
private void initBorderDefaults(UIDefaults table) { Object[] borderDefaults = { "TextField.border", Borders.getTextFieldBorder(), "PasswordField.border", Borders.getTextFieldBorder(), "FilterTextField.border", Borders.getTextFieldBorder(), "FormattedTextField.border", Borders.getTextFieldBorder(), "TextArea.border", Borders.getTextFieldBorder(), "SplitPane.border", Borders.getSplitPaneBorder(), "ScrollPane.border", Borders.getScrollPaneBorder(), "InternalFrame.border", Borders.getInternalFrameBorder(), "Table.scrollPaneBorder", null, // removed // table // border, // original: // Borders.getSplitPaneBorder() "Table.tabbedPaneBorder", null, // remove double borders "ToolBar.border", Borders.getToolBarBorder(), "Spinner.border", Borders.getSpinnerBorder(), "ComboBox.border", Borders.getComboBoxBorder(), "Button.border", Borders.getEmptyButtonBorder(), "ToggleButton.border", Borders.getEmptyButtonBorder(), "ProgressBar.border", Borders.getProgressBarBorder(), "PopupMenu.border", Borders.getPopupMenuBorder(), "CheckBox.border", Borders.getCheckBoxBorder(), "RadioButton.border", Borders.getCheckBoxBorder(), "ToolTip.border", Borders.getToolTipBorder(), "MenuBar.border", Borders.getMenuBarBorder(), "CheckBox.icon", IconFactory.getCheckBoxIcon(), "RadioButton.icon", IconFactory.getRadioButtonIcon(), "ComboBox.focusCellHighlightBorder", Borders.getComboBoxListCellRendererFocusBorder(), }; table.putDefaults(borderDefaults); }
Example #17
Source File: NimbusLookAndFeel.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Creates the value retrieved from the <code>UIDefaults</code> table. * The object is created each time it is accessed. * * @param table a <code>UIDefaults</code> table * @return the created <code>Object</code> */ @Override public Object createValue(UIDefaults table) { Object obj = null; // check specified state if (state!=null){ obj = uiDefaults.get(prefix+"["+state+"]."+suffix); } // check enabled state if (obj==null){ obj = uiDefaults.get(prefix+"[Enabled]."+suffix); } // check for defaults if (obj==null){ if (isFont) { obj = uiDefaults.get("defaultFont"); } else { obj = uiDefaults.get(suffix); } } return obj; }
Example #18
Source File: SwingCommonModule.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Initializes the module. Use this method to perform all initial setup operations. This method is called only once in * a modules lifetime. If the initializing cannot be completed, throw a ModuleInitializeException to indicate the * error,. The module will not be available to the system. * * @param subSystem * the subSystem. * @throws ModuleInitializeException * if an error ocurred while initializing the module. */ public void initialize( final SubSystem subSystem ) throws ModuleInitializeException { if ( subSystem.getExtendedConfig().getBoolProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.base.SwingDialogTranslation" ) ) { //$NON-NLS-1$ final ResourceBundle resources = ResourceBundle.getBundle( SwingCommonModule.BUNDLE_NAME ); final UIDefaults defaults = UIManager.getDefaults(); final Enumeration en = resources.getKeys(); while ( en.hasMoreElements() ) { try { final String keyName = (String) en.nextElement(); defaults.put( keyName, resources.getObject( keyName ) ); } catch ( Exception e ) { // Ignored; if it happens, we would not care that much .. } } } }
Example #19
Source File: XTextAreaPeer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override protected void installKeyboardActions() { super.installKeyboardActions(); JTextComponent comp = getComponent(); UIDefaults uidefaults = XToolkit.getUIDefaults(); String prefix = getPropertyPrefix(); InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap"); if (map != null) { SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED, map); } }
Example #20
Source File: WrongBackgroundColor.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws InvocationTargetException, InterruptedException { SwingUtilities.invokeAndWait(() -> { UIDefaults ui = UIManager.getDefaults(); ui.put("control", new ColorUIResource(54, 54, 54)); final JDialog dialog = new JDialog(); final JFrame frame = new JFrame(); frame.pack(); dialog.pack(); final Color dialogBackground = dialog.getBackground(); final Color frameBackground = frame.getBackground(); frame.dispose(); dialog.dispose(); if (!dialogBackground.equals(frameBackground)) { System.err.println("Expected:" + frameBackground); System.err.println("Actual:" + dialogBackground); throw new RuntimeException("Wrong background color"); } }); }
Example #21
Source File: ContrastMetalTheme.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public void addCustomEntriesToTable(UIDefaults table) { Border blackLineBorder = new BorderUIResource(new LineBorder(getBlack())); Border whiteLineBorder = new BorderUIResource(new LineBorder(getWhite())); Object textBorder = new BorderUIResource(new CompoundBorder( blackLineBorder, new BasicBorders.MarginBorder())); table.put("ToolTip.border", blackLineBorder); table.put("TitledBorder.border", blackLineBorder); table.put("Table.focusCellHighlightBorder", whiteLineBorder); table.put("Table.focusCellForeground", getWhite()); table.put("TextField.border", textBorder); table.put("PasswordField.border", textBorder); table.put("TextArea.border", textBorder); table.put("TextPane.font", textBorder); }
Example #22
Source File: XTextFieldPeer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override protected void installKeyboardActions() { super.installKeyboardActions(); JTextComponent comp = getComponent(); UIDefaults uidefaults = XToolkit.getUIDefaults(); String prefix = getPropertyPrefix(); InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap"); if (map != null) { SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED, map); } }
Example #23
Source File: NimbusStyle.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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 #24
Source File: SynthParser.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void endInputMap() throws SAXException { if (_inputMapID != null) { register(_inputMapID, new UIDefaults.LazyInputMap( _inputMapBindings.toArray(new Object[_inputMapBindings. size()]))); } _inputMapBindings.clear(); _inputMapID = null; }
Example #25
Source File: NimbusStyle.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 #26
Source File: SynthParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void endInputMap() throws SAXException { if (_inputMapID != null) { register(_inputMapID, new UIDefaults.LazyInputMap( _inputMapBindings.toArray(new Object[_inputMapBindings. size()]))); } _inputMapBindings.clear(); _inputMapID = null; }
Example #27
Source File: LuckInternalFrameUIBundle.java From littleluck with Apache License 2.0 | 5 votes |
@Override protected void installOther(UIDefaults table) { UIManager.put(TITLEPANE_HEIGHT, 26); table.put(LAYOUTTITLEPANEATORIGIN, Boolean.FALSE); }
Example #28
Source File: ColorCustomizationTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void testInheritance() { Color defaultColor = label.getBackground(); // more specific setting is in global defaults UIManager.put("Label[Enabled].background", new ColorUIResource(Color.RED)); // less specific one is in overrides UIDefaults defs = new UIDefaults(); defs.put("Label.background", new ColorUIResource(Color.GREEN)); // global wins label.putClientProperty("Nimbus.Overrides", defs); check(Color.RED); // now override wins label.putClientProperty("Nimbus.Overrides.InheritDefaults", false); check(Color.GREEN); // global is back label.putClientProperty("Nimbus.Overrides.InheritDefaults", true); check(Color.RED); // back to default color UIManager.put("Label[Enabled].background", null); label.putClientProperty("Nimbus.Overrides.InheritDefaults", false); label.putClientProperty("Nimbus.Overrides", null); check(defaultColor); }
Example #29
Source File: ColorCustomizationTest.java From hottub with GNU General Public License v2.0 | 5 votes |
void testInheritance() { Color defaultColor = label.getBackground(); // more specific setting is in global defaults UIManager.put("Label[Enabled].background", new ColorUIResource(Color.RED)); // less specific one is in overrides UIDefaults defs = new UIDefaults(); defs.put("Label.background", new ColorUIResource(Color.GREEN)); // global wins label.putClientProperty("Nimbus.Overrides", defs); check(Color.RED); // now override wins label.putClientProperty("Nimbus.Overrides.InheritDefaults", false); check(Color.GREEN); // global is back label.putClientProperty("Nimbus.Overrides.InheritDefaults", true); check(Color.RED); // back to default color UIManager.put("Label[Enabled].background", null); label.putClientProperty("Nimbus.Overrides.InheritDefaults", false); label.putClientProperty("Nimbus.Overrides", null); check(defaultColor); }
Example #30
Source File: ColorEditor.java From netbeans with Apache License 2.0 | 5 votes |
/** Initialized fields used in Swing Palette. */ private static void initSwingConstants() { if (swingColorNames != null) return; UIDefaults def = UIManager.getDefaults (); Enumeration e = def.keys (); java.util.TreeSet<String> names = new java.util.TreeSet<String>(); while (e.hasMoreElements ()) { Object k = e.nextElement (); if (! (k instanceof String)) continue; Object v = def.get (k); if (! (v instanceof Color)) continue; names.add((String)k); } swingColorNames = new String [names.size ()]; names.toArray(swingColorNames); swingColors = new Color [swingColorNames.length]; int i, k = swingColorNames.length; for (i = 0; i < k; i++) swingColors [i] = (Color) def.get (swingColorNames [i]); }