private static int getLFHeightAdjustment() { LookAndFeel lf = UIManager.getLookAndFeel(); String lfID = lf.getID(); logger.fine("createSingleLineEditor(): current L&F = '"+lfID+"'"); if ("Metal".equals(lfID)) { return 0; } if ("GTK".equals(lfID)) { return 2; } if ("Motif".equals(lfID)) { return 3; } if ("Nimbus".equals(lfID)) { return 0; } if ("Aqua".equals(lfID)) { return -2; } return 0; }
static void applyNbSkin() { LookAndFeel lookAndFeel = UIManager.getLookAndFeel(); String name = lookAndFeel.getName(); switch (name) { case "Mac OS X": name = "mac"; break; case "Metal": name = "metal"; break; case "GTK look and feel": name = "gtk"; break; case "Nimbus": name = "nimbus"; break; case "Windows": name = "win"; break; case "Darcula": name = "darcula"; break; } final String resource = "nbres:/org/netbeans/modules/htmlui/css/wizard-" + name + ".css"; loadCss(resource); }
private boolean isDarkLookAndFeel() { String className = NbPreferences.root().node( "laf" ).get( "laf", null ); if( null == className ) return false; ClassLoader loader = Lookup.getDefault().lookup( ClassLoader.class ); if( null == loader ) loader = ClassLoader.getSystemClassLoader(); try { Class klazz = loader.loadClass( className ); LookAndFeel laf = ( LookAndFeel ) klazz.newInstance(); return laf.getDefaults().getBoolean( "nb.dark.theme" ); //NOI18N } catch( Exception e ) { //ignore } return false; }
/** {@inheritDoc} */ @Override protected void paintComponent(Graphics graphics) { // Surchargée pour dessiner le fond avec gradient final LookAndFeel lookAndFeel = UIManager.getLookAndFeel(); final String lafName = lookAndFeel != null ? lookAndFeel.getName() : null; if ("Substance".equals(lafName)) { super.paintComponent(graphics); // le gradient fonctionne mal en substance ? } final Color startColor = getBackground(); final Color endColor = GRADIENT_COLOR; final int w = getWidth(); final int h = getHeight(); // l'image du gradient pourrait être mise en cache, mais ce n'est pas grave final Paint paint = new GradientPaint(0, h / 2f, startColor, 1, h, endColor, false); final Graphics2D graphix = (Graphics2D) graphics.create(); graphix.setPaint(paint); graphix.fillRect(0, 0, w, h); graphix.dispose(); }
/** * Overridden to message super and forward the method to the tree. Since * the tree is not actually in the component hierarchy it will never receive * this unless we forward it in this manner. */ //----------// // updateUI // //----------// @Override public void updateUI () { super.updateUI(); if (tree != null) { tree.updateUI(); } // Use the tree's default foreground and background colors in the // table. LookAndFeel.installColorsAndFont(this, "Tree.background", "Tree.foreground", "Tree.font"); }
protected void addBasicDefaults(LookAndFeelAddons addon, List defaults) { defaults.add(JTipOfTheDay.uiClassID); defaults.add(BasicTipOfTheDayUI.class.getName()); defaults.add("TipOfTheDay.font"); defaults.add(UIManager.getFont("TextPane.font")); defaults.add("TipOfTheDay.tipFont"); defaults.add(UIManager.getFont("Label.font").deriveFont(Font.BOLD, 13f)); defaults.add("TipOfTheDay.background"); defaults.add(new ColorUIResource(Color.white)); defaults.add("TipOfTheDay.icon"); defaults.add(LookAndFeel.makeIcon(BasicTipOfTheDayUI.class, "TipOfTheDay24.gif")); defaults.add("TipOfTheDay.border"); defaults.add(new BorderUIResource(BorderFactory.createLineBorder(new Color( 117, 117, 117)))); addResource(defaults, "com.l2fprod.common.swing.plaf.basic.resources.TipOfTheDay"); }
protected void addWindowsDefaults(LookAndFeelAddons addon, List defaults) { super.addWindowsDefaults(addon, defaults); defaults.add(JTipOfTheDay.uiClassID); defaults.add(WindowsTipOfTheDayUI.class.getName()); defaults.add("TipOfTheDay.background"); defaults.add(new ColorUIResource(128, 128, 128)); defaults.add("TipOfTheDay.font"); defaults.add(UIManager.getFont("Label.font").deriveFont(13f)); defaults.add("TipOfTheDay.icon"); defaults.add(LookAndFeel.makeIcon(WindowsTipOfTheDayUI.class, "tipoftheday.png")); defaults.add("TipOfTheDay.border"); defaults .add(new BorderUIResource(new WindowsTipOfTheDayUI.TipAreaBorder())); addResource(defaults, "com.l2fprod.common.swing.plaf.windows.resources.TipOfTheDay"); }
protected void installDefaults() { group.setOpaque(true); group.setBorder(createPaneBorder()); ((JComponent)group.getContentPane()).setBorder(createContentPaneBorder()); LookAndFeel.installColorsAndFont( group, "TaskPaneGroup.background", "TaskPaneGroup.foreground", "TaskPaneGroup.font"); LookAndFeel.installColorsAndFont( (JComponent)group.getContentPane(), "TaskPaneGroup.background", "TaskPaneGroup.foreground", "TaskPaneGroup.font"); }
/** * This method installs defaults for the JOptionPane. */ protected void installDefaults() { LookAndFeel.installColorsAndFont(optionPane, "OptionPane.background", "OptionPane.foreground", "OptionPane.font"); LookAndFeel.installBorder(optionPane, "OptionPane.border"); optionPane.setOpaque(true); minimumSize = UIManager.getDimension("OptionPane.minimumSize"); // FIXME: Image icons don't seem to work properly right now. // Once they do, replace the synthetic icons with these ones. /* warningIcon = (IconUIResource) defaults.getIcon("OptionPane.warningIcon"); infoIcon = (IconUIResource) defaults.getIcon("OptionPane.informationIcon"); errorIcon = (IconUIResource) defaults.getIcon("OptionPane.errorIcon"); questionIcon = (IconUIResource) defaults.getIcon("OptionPane.questionIcon"); */ }
/** * Initializes any default properties that this UI has from the defaults for * the Basic look and feel. */ protected void installDefaults() { LookAndFeel.installBorder(menuItem, "Menu.border"); LookAndFeel.installColorsAndFont(menuItem, "Menu.background", "Menu.foreground", "Menu.font"); menuItem.setMargin(UIManager.getInsets("Menu.margin")); acceleratorFont = UIManager.getFont("Menu.acceleratorFont"); acceleratorForeground = UIManager.getColor("Menu.acceleratorForeground"); acceleratorSelectionForeground = UIManager.getColor("Menu.acceleratorSelectionForeground"); selectionBackground = UIManager.getColor("Menu.selectionBackground"); selectionForeground = UIManager.getColor("Menu.selectionForeground"); arrowIcon = UIManager.getIcon("Menu.arrowIcon"); oldBorderPainted = UIManager.getBoolean("Menu.borderPainted"); ((JMenu) menuItem).setDelay(200); }
public void updateUI() { super.updateUI(); LookAndFeel currentLookAndFeel = UIManager.getLookAndFeel(); if (currentLookAndFeel != null) { String current = currentLookAndFeel.getClass().getName(); for (Enumeration<AbstractButton> buttons = getLookAndFeelGroup().getElements(); buttons.hasMoreElements();) { AbstractButton button = buttons.nextElement(); if (button.getActionCommand().equals(current)) { button.setSelected(true); break; } } } }
protected void updateLookAndFeels() { clearButtons(); LookAndFeel currentLookAndFeel = UIManager.getLookAndFeel(); String current = currentLookAndFeel == null ? "" : currentLookAndFeel.getName(); LookAndFeelInfo[] infoArray = UIManager.getInstalledLookAndFeels(); if (infoArray == null || infoArray.length == 0) { return; } for (LookAndFeelInfo info : infoArray) { JRadioButtonMenuItem button = new JRadioButtonMenuItem(info.getName()); button.setActionCommand(info.getClassName()); if (info.getName().equals(current)) button.setSelected(true); addButton(button); } }
public void installDefaults(AbstractButton b) { super.installDefaults(b); LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE); LookAndFeel.installProperty(b, "opaque", Boolean.FALSE); btnColorInfo = (LuckButtonColorInfo) UIManager.get(LuckButtonUIBundle.COLOR_INFO); // 使用配置颜色替换默认字体颜色 // Replace the default font color with the configured color if(b.getForeground() instanceof ColorUIResource) { b.setForeground(btnColorInfo.getFontColor()); } listener = new ButtonPropertyChangeListener(); b.addPropertyChangeListener(listener); }
/** * Called by the KeyboardHandler when a popup is made visible. */ void installKeyboardActionsImpl() { Object[] bindings; if (popupMenu.getComponentOrientation().isLeftToRight()) { bindings = (Object[]) SharedUIDefaults.get("PopupMenu.selectedWindowInputMapBindings"); } else { bindings = (Object[]) SharedUIDefaults.get ("PopupMenu.selectedWindowInputMapBindings.RightToLeft"); } InputMap inputMap = LookAndFeel.makeComponentInputMap(popupMenu, bindings); SwingUtilities.replaceUIInputMap(popupMenu, JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap); // Install ActionMap. SwingUtilities.replaceUIActionMap(popupMenu, getActionMap()); }
/** * This method installs the defaults that are defined in the Basic look and * feel for this {@link JMenuItem}. */ protected void installDefaults() { String prefix = getPropertyPrefix(); LookAndFeel.installBorder(menuItem, prefix + ".border"); LookAndFeel.installColorsAndFont(menuItem, prefix + ".background", prefix + ".foreground", prefix + ".font"); menuItem.setMargin(UIManager.getInsets(prefix + ".margin")); acceleratorFont = UIManager.getFont(prefix + ".acceleratorFont"); acceleratorForeground = UIManager.getColor(prefix + ".acceleratorForeground"); acceleratorSelectionForeground = UIManager.getColor(prefix + ".acceleratorSelectionForeground"); selectionBackground = UIManager.getColor(prefix + ".selectionBackground"); selectionForeground = UIManager.getColor(prefix + ".selectionForeground"); acceleratorDelimiter = UIManager.getString(prefix + ".acceleratorDelimiter"); checkIcon = UIManager.getIcon(prefix + ".checkIcon"); menuItem.setHorizontalTextPosition(SwingConstants.TRAILING); menuItem.setHorizontalAlignment(SwingConstants.LEADING); }
public void propertyChange(PropertyChangeEvent event) { JRootPane source = (JRootPane) event.getSource(); String propertyName = event.getPropertyName(); if (propertyName.equals("defaultButton")) { Object newValue = event.getNewValue(); InputMap im = SwingUtilities.getUIInputMap(source, JComponent.WHEN_IN_FOCUSED_WINDOW); if (newValue != null) { Object[] keybindings = (Object[]) UIManager.get( "RootPane.defaultButtonWindowKeyBindings"); LookAndFeel.loadKeyBindings(im, keybindings); } else { im.clear(); } } }
/** * {@inheritDoc} */ @Override protected void addWindowsDefaults(LookAndFeelAddons addon, DefaultsList defaults) { super.addWindowsDefaults(addon, defaults); Font font = UIManagerExt.getSafeFont("Label.font", new Font("Dialog", Font.PLAIN, 12)); font = font.deriveFont(13f); defaults.add(JXCategory.uiClassID, WindowsTipOfTheDayUI.class.getName()); defaults.add("Category.background", new ColorUIResource(Color.GRAY)); defaults.add("Category.font", new FontUIResource(font)); defaults.add("Category.icon", LookAndFeel.makeIcon(WindowsTipOfTheDayUI.class, "resources/tipoftheday.png")); defaults.add("Category.border" ,new BorderUIResource(new WindowsTipOfTheDayUI.TipAreaBorder())); UIManagerExt.addResourceBundle( "org.jdesktop.swingx.plaf.windows.resources.TipOfTheDay"); }
@Override protected void addBasicDefaults(LookAndFeelAddons addon, DefaultsList defaults) { super.addBasicDefaults(addon, defaults); Font font = UIManagerExt.getSafeFont("Label.font", new Font("Dialog", Font.PLAIN, 12)); font = font.deriveFont(Font.BOLD, 13f); defaults.add(JXTipOfTheDay.uiClassID, BasicTipOfTheDayUI.class.getName()); defaults.add("TipOfTheDay.font", UIManagerExt.getSafeFont("TextPane.font", new FontUIResource("Serif", Font.PLAIN, 12))); defaults.add("TipOfTheDay.tipFont", new FontUIResource(font)); defaults.add("TipOfTheDay.background", new ColorUIResource(Color.WHITE)); defaults.add("TipOfTheDay.icon", LookAndFeel.makeIcon(BasicTipOfTheDayUI.class, "resources/TipOfTheDay24.gif")); defaults.add("TipOfTheDay.border", new BorderUIResource( BorderFactory.createLineBorder(new Color(117, 117, 117)))); UIManagerExt.addResourceBundle( "org.jdesktop.swingx.plaf.basic.resources.TipOfTheDay"); }
/** * {@inheritDoc} */ @Override protected void addWindowsDefaults(LookAndFeelAddons addon, DefaultsList defaults) { super.addWindowsDefaults(addon, defaults); Font font = UIManagerExt.getSafeFont("Label.font", new Font("Dialog", Font.PLAIN, 12)); font = font.deriveFont(13f); defaults.add(JXTipOfTheDay.uiClassID, WindowsTipOfTheDayUI.class.getName()); defaults.add("TipOfTheDay.background", new ColorUIResource(Color.GRAY)); defaults.add("TipOfTheDay.font", new FontUIResource(font)); defaults.add("TipOfTheDay.icon", LookAndFeel.makeIcon(WindowsTipOfTheDayUI.class, "resources/tipoftheday.png")); defaults.add("TipOfTheDay.border" ,new BorderUIResource(new WindowsTipOfTheDayUI.TipAreaBorder())); UIManagerExt.addResourceBundle( "org.jdesktop.swingx.plaf.windows.resources.TipOfTheDay"); }
/** * This method installs the defaults given by the Look and Feel. */ protected void installDefaults() { LookAndFeel.installColors(splitPane, "SplitPane.background", "SplitPane.foreground"); LookAndFeel.installBorder(splitPane, "SplitPane.border"); divider = createDefaultDivider(); divider.setBorder(UIManager.getBorder("SplitPaneDivider.border")); resetLayoutManager(); nonContinuousLayoutDivider = createDefaultNonContinuousLayoutDivider(); splitPane.add(divider, JSplitPane.DIVIDER); // There is no need to add the nonContinuousLayoutDivider. dividerSize = UIManager.getInt("SplitPane.dividerSize"); splitPane.setDividerSize(dividerSize); divider.setDividerSize(dividerSize); splitPane.setOpaque(true); }
/** * Overridden to message super and forward the method to the tree. Since the * tree is not actually in the component hieachy it will never receive this * unless we forward it in this manner. */ public void updateUI() { super.updateUI(); if (tree != null) { tree.updateUI(); } // Use the tree's default foreground and background colors in the // table. LookAndFeel.installColorsAndFont(this, "Tree.background", "Tree.foreground", "Tree.font"); }
public static final LookAndFeelType getLAF() { if(lookAndFeelType==null) { try { initializeLookAndFeel(); } catch (InitializationException e) { LogManager.log(e); } lookAndFeelType = LookAndFeelType.DEFAULT; if (!uiUnavailable && UiMode.getCurrentUiMode() == UiMode.SWING) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf != null) { String id = laf.getID(); for (LookAndFeelType type : LookAndFeelType.values()) { if (id.equals(LookAndFeelType.WINDOWS_XP.getId()) || id.equals(LookAndFeelType.WINDOWS_CLASSIC.getId())) { final Object object = Toolkit.getDefaultToolkit(). getDesktopProperty(WINDOWS_XP_THEME_MARKER_PROPERTY); boolean xpThemeActive = false; if (object != null) { xpThemeActive = (Boolean) object; } lookAndFeelType = (xpThemeActive) ? LookAndFeelType.WINDOWS_XP : LookAndFeelType.WINDOWS_CLASSIC; break; } else if (id.equals(type.getId())) { lookAndFeelType = type; break; } } } } } return lookAndFeelType; }
/** * Factory methods for obtaining the current <code>LayoutStyle</code> * object appropriate for the current look and feel. * * @return the current LayoutStyle instance */ public static LayoutStyle getSharedInstance() { Object layoutImpl = UIManager.get("LayoutStyle.instance"); if (layoutImpl != null && (layoutImpl instanceof LayoutStyle)) { return (LayoutStyle)layoutImpl; } LookAndFeel currentLAF = UIManager.getLookAndFeel(); if (layoutStyle == null || currentLAF != laf) { laf = currentLAF; String lafID= laf.getID(); if (USE_CORE_LAYOUT_STYLE) { layoutStyle = new SwingLayoutStyle(); } else if ("Metal" == lafID) { layoutStyle = new MetalLayoutStyle(); } else if ("Windows" == lafID) { layoutStyle = new WindowsLayoutStyle(); } else if ("GTK" == lafID) { layoutStyle = new GnomeLayoutStyle(); } else if ("Aqua" == lafID) { layoutStyle = new AquaLayoutStyle(); } else { layoutStyle = new LayoutStyle(); } } return layoutStyle; }
@Override public void updateUI() { super.updateUI(); setLineWrap(true); setWrapStyleWord(true); setHighlighter(null); setEditable(false); setFocusable(false); LookAndFeel.installBorder(this, LABEL_BORDER); LookAndFeel.installColorsAndFont(this, LABEL_BACKGROUND, LABEL_FOREGROUND, LABEL_FONT); }
/** * Sets the parent of the passed in ActionMap to be the audio action * map. */ static void installAudioActionMap(ActionMap map) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { map.setParent(((BasicLookAndFeel)laf).getAudioActionMap()); } }
/** * Helper method to play a named sound. * * @param c JComponent to play the sound for. * @param actionKey Key for the sound. */ static void playSound(JComponent c, Object actionKey) { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf instanceof BasicLookAndFeel) { ActionMap map = c.getActionMap(); if (map != null) { Action audioAction = map.get(actionKey); if (audioAction != null) { // pass off firing the Action to a utility method ((BasicLookAndFeel)laf).playSound(audioAction); } } } }
static void initUIDefaults() { try { // Load Defaults from MotifLookAndFeel // This dummy load is necessary to get SystemColor initialized. !!!!!! Color c = SystemColor.text; LookAndFeel lnf = new XAWTLookAndFeel(); uidefaults = lnf.getDefaults(); } catch (Exception e) { e.printStackTrace(); } }