protected static void configureNimbusToTangoColors() { UIManager.put("control", ALUMINIUM_1); UIManager.put("info", BUTTER_1); UIManager.put("nimbusAlertYellow", BUTTER_2); UIManager.put("nimbusBase", SKY_BLUE_3); UIManager.put("nimbusDisabledText", ALUMINIUM_4); UIManager.put("nimbusFocus", SKY_BLUE_1); UIManager.put("nimbusGreen", CHAMELEON_1); UIManager.put("nimbusInfoBlue", SKY_BLUE_2); UIManager.put("nimbusLightBackground", Color.WHITE); UIManager.put("nimbusOrange", ORANGE_2); UIManager.put("nimbusRed", SCARLET_2); UIManager.put("nimbusSelectedText", Color.WHITE); UIManager.put("nimbusSelectionBackground", SKY_BLUE_2); UIManager.put("text", Color.BLACK); UIManager.put("activeCaption", ALUMINIUM_3); UIManager.put("background", ALUMINIUM_2); UIManager.put("controlDkShadow", ALUMINIUM_4); UIManager.put("controlHighlight", ALUMINIUM_1); UIManager.put("controlLHighlight", ALUMINIUM_6); UIManager.put("controlShadow", ALUMINIUM_2); UIManager.put("controlText", Color.BLACK); UIManager.put("desktop", SKY_BLUE_1); UIManager.put("inactiveCaption", ALUMINIUM_3); UIManager.put("infoText", Color.BLACK); UIManager.put("menu", ALUMINIUM_1); UIManager.put("menuText", Color.BLACK); UIManager.put("nimbusBlueGrey", ALUMINIUM_1); UIManager.put("nimbusBorder", ALUMINIUM_4);
/** * Sets some sensible defaults for swing. * IMPORTANT! Needs to be called before main frame creation */ public static void setupDefaults() { // Force heavy-weight popups/tooltips. // Prevents them from being obscured by the game applet. ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setInitialDelay(300); JPopupMenu.setDefaultLightWeightPopupEnabled(false); UIManager.put("Button.foreground", Color.WHITE); UIManager.put("MenuItem.foreground", Color.WHITE); UIManager.put("Panel.background", ColorScheme.DARK_GRAY_COLOR); UIManager.put("ScrollBarUI", CustomScrollBarUI.class.getName()); UIManager.put("TextField.selectionBackground", ColorScheme.BRAND_ORANGE_TRANSPARENT); UIManager.put("TextField.selectionForeground", Color.WHITE); UIManager.put("FormattedTextField.selectionBackground", ColorScheme.BRAND_ORANGE_TRANSPARENT); UIManager.put("FormattedTextField.selectionForeground", Color.WHITE); UIManager.put("TextArea.selectionBackground", ColorScheme.BRAND_ORANGE_TRANSPARENT); UIManager.put("TextArea.selectionForeground", Color.WHITE); // Do not render shadows under popups/tooltips. // Fixes black boxes under popups that are above the game applet. System.setProperty("jgoodies.popupDropShadowEnabled", "false"); // Do not fill in background on repaint. Reduces flickering when // the applet is resized. System.setProperty("sun.awt.noerasebackground", "true"); }
private static void setGlobalUIFontSize(final int fontSize){ Font f = new Font(Font.DIALOG, Font.PLAIN, fontSize); //UIManager.put("Label.font", f); //UIManager.put("Button.font", f); //UIManager.put("RadioButton.font", f); ArrayList<String> excludes = new ArrayList<>(); //excludes.add("TitledBorder.font"); //excludes.add("MenuBar.font"); //excludes.add("MenuItem.font"); //excludes.add("MenuItem.acceleratorFont"); //excludes.add("Menu.font"); //excludes.add("TabbedPane.font"); excludes.add(""); Enumeration itr = UIManager.getDefaults().keys(); while(itr.hasMoreElements()){ Object o = itr.nextElement(); if(o instanceof String) { String key = (String) o; Object value = UIManager.get (key); if ((value instanceof javax.swing.plaf.FontUIResource) && (!excludes.contains(key))){ LOG.fine(key); UIManager.put (key, f); } } } }
/** * Sets default Swing font. * IMPORTANT! Needs to be called before main frame creation * * @param font the new font to use */ public static void setFont(@Nonnull final Font font) { final FontUIResource f = new FontUIResource(font); final Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { final Object key = keys.nextElement(); final Object value = UIManager.get(key); if (value instanceof FontUIResource) { UIManager.put(key, f); } } }
public static void increaseDefaultFont(float multiplier) { for (Enumeration keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value != null && value instanceof FontUIResource) { FontUIResource fontUIResource = (FontUIResource) value; UIManager.put(key, fontUIResource.deriveFont(fontUIResource.getSize() * multiplier)); } } }
UIManager.put("FileChooser.useSystemExtensionHiding", false); JFileChooser jfc = new JFileChooser(Utils.getWorkingDirectory()); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); }); configUrlFileChooserButton.addActionListener(arg0 -> { UIManager.put("FileChooser.useSystemExtensionHiding", false); JFileChooser jfc = new JFileChooser(Utils.getWorkingDirectory()); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
/** * Initializes Swing's look and feel to the system native look and feel. * On Mac, uses the system menu bar. */ private void initLookAndFeel() { try { UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName()); } catch (Exception ignored) { } System.setProperty("apple.laf.useScreenMenuBar", "true"); UIManager.put("Table.alternateRowColor", new Color(243, 246, 250)); }
@Override public void mouseExited(MouseEvent me) { ToolTipManager.sharedInstance().setDismissDelay(Constants.TOOLTIPS_DELAY_MS); UIManager.put("info", tooltipBackground); } });
@Override public void mouseEntered(MouseEvent me) { ToolTipManager.sharedInstance().setDismissDelay(100 * 1000); UIManager.put("info", Color.DARK_GRAY); }
public static void setDefaultFont (Font font) { for (Object key : Collections.list(UIManager.getDefaults().keys())) { Object value = UIManager.get(key); if (value instanceof javax.swing.plaf.FontUIResource) { UIManager.put(key, font); } } } }
@Override public void run() { try { URL envelopeImage = getClass().getResource(Configuration.INSTANCE.get("application.icon.path")); if (envelopeImage != null) { Application.getApplication().setDockIconImage(Toolkit.getDefaultToolkit().getImage(envelopeImage)); } } catch (RuntimeException e) { LOGGER.debug("Error: {} - This is probably because we run on a non-Mac platform and these components are not implemented", e.getMessage()); } catch (Exception e) { LOGGER.error("", e); } System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", Configuration.INSTANCE.get("application.name")); UIManager.put("swing.boldMetal", Boolean.FALSE); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { LOGGER.error("", e); } new MainFrame(); } });
UIManager.put("Button.disabledText", new Color(40,40,255));
/** * Get the InputMap to use for the UI.<p> * * This method is not named <code>getInputMap()</code> because there is * a package-private method in <code>BasicTextAreaUI</code> with that name. * Thus, creating a new method with that name causes certain compilers to * issue warnings that you are not actually overriding the original method * (since it is package-private). */ protected InputMap getRTextAreaInputMap() { InputMap map = new InputMapUIResource(); InputMap shared = (InputMap)UIManager.get(SHARED_INPUT_MAP_NAME); if (shared==null) { shared = new RTADefaultInputMap(); UIManager.put(SHARED_INPUT_MAP_NAME, shared); } //KeyStroke[] keys = shared.allKeys(); //for (int i=0; i<keys.length; i++) // System.err.println(keys[i] + " -> " + shared.get(keys[i])); map.setParent(shared); return map; }
/** * Get the InputMap to use for the UI.<p> * * This method is not named <code>getInputMap()</code> because there is * a package-private method in <code>BasicTextAreaUI</code> with that name. * Thus, creating a new method with that name causes certain compilers to * issue warnings that you are not actually overriding the original method * (since it is package-private). */ @Override protected InputMap getRTextAreaInputMap() { InputMap map = new InputMapUIResource(); InputMap shared = (InputMap)UIManager.get(SHARED_INPUT_MAP_NAME); if (shared==null) { shared = new RSyntaxTextAreaDefaultInputMap(); UIManager.put(SHARED_INPUT_MAP_NAME, shared); } //KeyStroke[] keys = shared.allKeys(); //for (int i=0; i<keys.length; i++) // System.err.println(keys[i] + " -> " + shared.get(keys[i])); map.setParent(shared); return map; }
UIManager.put("Button.margin", new Insets(10, 10, 10, 10) ); ButtonCalculator frame = new ButtonCalculator(); frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
public AbilityPicker() { setSize(DIALOG_WIDTH, DIALOG_HEIGHT); initComponents(); jScrollPane2.setOpaque(false); jScrollPane2.getViewport().setOpaque(false); UIManager.put("ScrollBar.width", 17); jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI()); jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI()); }
public AbilityPicker(List<Object> choices, String message) { this.choices = choices; setSize(DIALOG_WIDTH, DIALOG_HEIGHT); if (message != null) { this.message = message + " (single-click)"; } initComponents(); jScrollPane2.setOpaque(false); jScrollPane2.getViewport().setOpaque(false); UIManager.put("ScrollBar.width", 17); jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI()); jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI()); }
/** * Returns an action map to use by a text area.<p> * * This method is not named <code>getActionMap()</code> because there is * a package-private method in <code>BasicTextAreaUI</code> with that name. * Thus, creating a new method with that name causes certain compilers to * issue warnings that you are not actually overriding the original method * (since it is package-private). * * @return The action map. * @see #createRTextAreaActionMap() */ private ActionMap getRTextAreaActionMap() { // Get the UIManager-cached action map; if this is the first // RTextArea created, create the action map and cache it. ActionMap map = (ActionMap)UIManager.get(getActionMapName()); if (map==null) { map = createRTextAreaActionMap(); UIManager.put(getActionMapName(), map); } ActionMap componentMap = new ActionMapUIResource(); componentMap.put("requestFocus", new FocusAction()); if (map != null) { componentMap.setParent(map); } return componentMap; }