/** * 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. */ 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"); }
void updateStyle(AbstractButton b) { SynthContext context = getContext(b, SynthConstants.ENABLED); SynthStyle oldStyle = style; style = SynthLookAndFeel.updateStyle(context, this); if (style != oldStyle) { if (b.getMargin() == null || (b.getMargin() instanceof UIResource)) { Insets margin = (Insets) style.get(context, getPropertyPrefix() + "margin"); if (margin == null) { // Some places assume margins are non-null. margin = SynthLookAndFeel.EMPTY_UIRESOURCE_INSETS; } b.setMargin(margin); } Object value = style.get(context, getPropertyPrefix() + "iconTextGap"); if (value != null) { LookAndFeel.installProperty(b, "iconTextGap", value); } value = style.get(context, getPropertyPrefix() + "contentAreaFilled"); LookAndFeel.installProperty(b, "contentAreaFilled", value != null ? value : Boolean.TRUE); if (oldStyle != null) { uninstallKeyboardActions(b); installKeyboardActions(b); } } }
protected void installDefaults(final JComponent c) { LookAndFeel.installColorsAndFont(c, "ToolTip.background", "ToolTip.foreground", "ToolTip.font"); LookAndFeel.installBorder(c, "ToolTip.border"); backgroundInactiveColor = UIManager.getColor("ToolTip.backgroundInactive"); foregroundInactiveColor = UIManager.getColor("ToolTip.foregroundInactive"); }
public void paint(final Graphics g, final JComponent c) { JComponent component = tooltip.getComponent(); if (component != null && component.isEnabled() || backgroundInactiveColor == null) { g.setColor(tooltip.getBackground()); LookAndFeel.installBorder(c, "ToolTip.border"); } else { g.setColor(backgroundInactiveColor); LookAndFeel.installBorder(c, "ToolTip.borderInactive"); } g.fillRect(0, 0, tooltip.getWidth(), tooltip.getHeight()); String tipText = tooltip.getTipText(); FontMetrics fm = Utilities.getFontMetrics(tooltip); Dimension stringSize = Utilities.getStringSize(tipText, fm); int textX = component instanceof AbstractButton && ((AbstractButton) component).getMnemonic() != 0 ? 4 : (tooltip.getWidth() - stringSize.width) / 2; int textY = fm.getAscent(); Color foreground = component != null && component.isEnabled() || foregroundInactiveColor == null ? tooltip.getForeground() : foregroundInactiveColor; Utilities.drawString(g, tipText, textX, textY, fm, foreground, -1); }
/** Installs the default colors, border, and painter of the task pane container. */ protected void installDefaults() { LookAndFeel.installColors( taskPane, "TaskPaneContainer.background", "TaskPaneContainer.foreground"); LookAndFeel.installBorder(taskPane, "TaskPaneContainer.border"); LookAndFeelAddons.installBackgroundPainter(taskPane, "TaskPaneContainer.backgroundPainter"); LookAndFeel.installProperty(taskPane, "opaque", Boolean.TRUE); }
/** * Loads the menu with the available look and feels for the application * * @return l and f menu */ JMenu buildLookAndFeelMenu() { String activeLookAndFeelName = UIManager.getLookAndFeel().getName(); // ButtonGroup buttonGroup = new ButtonGroup(); JMenu lfMenu = new JMenu(); lfMenu.setText(rb.getString("Menu.LookAndFeel.Name")); lfMenu.setMnemonic(jgnash.ui.util.Resource.getMnemonic("Menu.LookAndFeel.Mnemonic")); lfMenu.add(buildSubstanceMenu()); List<String> lookAndFeels = new ArrayList<>(); for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (isLookAndFeelAvailable(info.getClassName())) { lookAndFeels.add(info.getClassName()); } } for (String lookAndFeel : KNOWN) { if (isLookAndFeelAvailable(lookAndFeel)) { lookAndFeels.add(lookAndFeel); } } Collections.sort(lookAndFeels); for (String lookAndFeel : lookAndFeels) { try { Class<?> lnfClass = Class.forName(lookAndFeel); LookAndFeel newLAF = (LookAndFeel) lnfClass.newInstance(); JRadioButtonMenuItem button = new JRadioButtonMenuItem(); button.setText(newLAF.getName()); button.setActionCommand(lookAndFeel); button.setName(newLAF.getName()); button.addActionListener( e -> { Preferences pref = Preferences.userNodeForPackage(ThemeManager.class); pref.put(LF, e.getActionCommand()); restartUI(); }); lfButtonGroup.add(button); lfMenu.add(button); if (newLAF.getName().equals(activeLookAndFeelName)) { button.setSelected(true); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { Logger.getLogger(ThemeManager.class.getName()).log(Level.WARNING, null, e); } } return lfMenu; }
public static final LookAndFeelType getLAF() { if (lookAndFeelType == null) { try { initializeLookAndFeel(); } catch (InitializationException e) { LogManager.log(e); } lookAndFeelType = LookAndFeelType.DEFAULT; if (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; }
protected void installDefaults() { LookAndFeel.installColorsAndFont( optionPane, "OptionPane.background", "OptionPane.foreground", "OptionPane.font"); LookAndFeel.installBorder(optionPane, "OptionPane.border"); minimumSize = UIManager.getDimension("OptionPane.minimumSize"); LookAndFeel.installProperty(optionPane, "opaque", Boolean.TRUE); }
/** Sets whether this JInternalFrame is to use a palette border or not */ public void setPalette(boolean isPalette) { if (isPalette) { LookAndFeel.installBorder(frame, "InternalFrame.paletteBorder"); } else { LookAndFeel.installBorder(frame, "InternalFrame.border"); } titlePane.setPalette(isPalette); }
/** * A utility function that layers on top of the LookAndFeel's isSupportedLookAndFeel() method. * Returns true if the LookAndFeel is supported. Returns false if the LookAndFeel is not supported * and/or if there is any kind of error checking if the LookAndFeel is supported. * * <p>The L&F menu will use this method to detemine whether the various L&F options should be * active or inactive. */ protected boolean isAvailableLookAndFeel(String laf) { try { Class lnfClass = Class.forName(laf); LookAndFeel newLAF = (LookAndFeel) (lnfClass.newInstance()); return newLAF.isSupportedLookAndFeel(); } catch (Exception e) { // If ANYTHING weird happens, return false return false; } }
/** Installs the appropriate <code>Border</code> onto the <code>JRootPane</code>. */ void installBorder(JRootPane root) { int style = root.getWindowDecorationStyle(); if (style == JRootPane.NONE) { LookAndFeel.uninstallBorder(root); } else { LookAndFeel.installBorder(root, borderKeys[style]); } }
public static void setLookAndFeel(LookAndFeel newLookAndFeel) { if (look_and_feel != null) look_and_feel.uninitialize(); // Set the current default look and feel using a LookAndFeel object. look_and_feel = newLookAndFeel; look_and_feel.initialize(); // revalidate(); // repaint(); }
protected void installDefaults() { LookAndFeel.installProperty(progressBar, "opaque", Boolean.TRUE); LookAndFeel.installBorder(progressBar, "ProgressBar.border"); LookAndFeel.installColorsAndFont( progressBar, "ProgressBar.background", "ProgressBar.foreground", "ProgressBar.font"); cellLength = UIManager.getInt("ProgressBar.cellLength"); if (cellLength == 0) cellLength = 1; cellSpacing = UIManager.getInt("ProgressBar.cellSpacing"); selectionForeground = UIManager.getColor("ProgressBar.selectionForeground"); selectionBackground = UIManager.getColor("ProgressBar.selectionBackground"); }
/** This method installs the defaults as specified by the look and feel. */ protected void installDefaults() { LookAndFeel.installBorder(toolBar, "ToolBar.border"); LookAndFeel.installColorsAndFont( toolBar, "ToolBar.background", "ToolBar.foreground", "ToolBar.font"); dockingBorderColor = UIManager.getColor("ToolBar.dockingForeground"); dockingColor = UIManager.getColor("ToolBar.dockingBackground"); floatingBorderColor = UIManager.getColor("ToolBar.floatingForeground"); floatingColor = UIManager.getColor("ToolBar.floatingBackground"); }
/** Provide appropriate LAF feedback when a filter error occurs. */ public void provideErrorFeedback() { LookAndFeel laf = UIManager.getLookAndFeel(); if (laf == null) { Toolkit.getDefaultToolkit().beep(); } else { KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Component component = fm.getFocusOwner(); laf.provideErrorFeedback(component); } }
/** * Sets the frame type according to the specified type constant. This must be one of the * SwingConstants. */ private void setFrameType(String frameType) { if (frameType.equals(OPTION_DIALOG)) { LookAndFeel.installBorder(frame, "InternalFrame.optionDialogBorder"); titlePane.setPalette(false); } else if (frameType.equals(PALETTE_FRAME)) { LookAndFeel.installBorder(frame, "InternalFrame.paletteBorder"); titlePane.setPalette(true); } else { LookAndFeel.installBorder(frame, "InternalFrame.border"); titlePane.setPalette(false); } }
/** Returns whether the current LAF is Metal Steel. */ protected static boolean isMetalSteel() { if (!UIManager.getLookAndFeel().getName().equals("Metal")) { return false; } try { LookAndFeel laf = UIManager.getLookAndFeel(); laf.getClass().getMethod("getCurrentTheme", new Class[0]); return false; } catch (Exception e) { } return true; }
/** * A utility function that layers on top of the LookAndFeel's isSupportedLookAndFeel() method. * Returns true if the LookAndFeel is supported. Returns false if the LookAndFeel is not supported * and/or if there is any kind of error checking if the LookAndFeel is supported. * * <p>The Look and Feel menu will use this method to determine whether the various Look and Feel * options should be active or inactive. * * @param laf name of look and feel to search for * @return true if found */ @SuppressWarnings("rawtypes") private static boolean isLookAndFeelAvailable(final String laf) { try { Class lnfClass = Class.forName(laf); LookAndFeel newLAF = (LookAndFeel) lnfClass.newInstance(); return newLAF.isSupportedLookAndFeel(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { // If ANYTHING bad happens, return false Logger.getLogger(ThemeManager.class.getName()).log(Level.FINEST, e.getLocalizedMessage(), e); return false; } }
protected void installDefaults() { // Note: Omitting the following line was a bug from v1.3.01 until v1.3.04 // Note: The following method turned out to be new in 1.5. Therefore // replaced with progressBar.setOpaque(true) // LookAndFeel.installProperty(progressBar, "opaque", Boolean.TRUE); // removed again in 1.3.7 (because opaque progress bar // fills bounds with track [background] color) // progressBar.setOpaque(true); LookAndFeel.installBorder(progressBar, "ProgressBar.border"); LookAndFeel.installColorsAndFont( progressBar, "ProgressBar.background", "ProgressBar.foreground", "ProgressBar.font"); }
/** Connection Editor creating new Connection */ public CConnectionEditor() { super(); setName("ConnectionEditor"); CConnectionEditor_MouseListener ml = new CConnectionEditor_MouseListener(); // Layout m_text.setEditable(false); m_text.setBorder(null); m_text.addMouseListener(ml); m_server.setIcon(new ImageIcon(getClass().getResource("Server16.gif"))); m_server.setFocusable(false); m_server.setBorder(null); m_server.setOpaque(true); m_server.addMouseListener(ml); m_db.setIcon(new ImageIcon(getClass().getResource("Database16.gif"))); m_db.setFocusable(false); m_db.setBorder(null); m_db.setOpaque(true); m_db.addMouseListener(ml); LookAndFeel.installBorder(this, "TextField.border"); // setLayout(new BorderLayout(0, 0)); add(m_server, BorderLayout.WEST); add(m_text, BorderLayout.CENTER); add(m_db, BorderLayout.EAST); } // CConnectionEditor
protected void uninstallDefaults(final JComponent c) { Utilities.uninstallColorsAndFont(c); LookAndFeel.uninstallBorder(c); backgroundInactiveColor = null; foregroundInactiveColor = null; }
/** * Creates an <code>InputMap</code> with the bindings that are passed in. * * @param table a <code>UIDefaults</code> table * @return the <code>InputMap</code> */ public Object createValue(UIDefaults table) { if (bindings != null) { InputMap km = LookAndFeel.makeInputMap(bindings); return km; } return null; }
/** * Tells the look and feel to reset some of the values for this component so that it doesn't use * JTextArea's default values. * * <p>DO NOT CALL THIS METHOD YOURSELF! */ public void updateUI() { super.updateUI(); // setLineWrap(true); setWrapStyleWord(true); setHighlighter(null); setEditable(false); LookAndFeel.installBorder(this, "Label.border"); LookAndFeel.installColorsAndFont(this, "Label.background", "Label.foreground", "Label.font"); if (resizeHandler != null) { resizeHandler.componentResized(null); } // update restricted size SizePolicy policy = (SizePolicy) getClientProperty(SizePolicy.class); if (policy != null) { GUIUtils.restrictSize(this, policy); } }
/* * Load key bindings from UIDefaults to InputMap. This occurs * when the default button is assigned. */ private void loadDefaultButtonKeyBindings(final JComponent root) { Object[] bindings = ((Object[]) UIManager.get("RootPane.defaultButtonWindowKeyBindings")); if (bindings != null) { InputMap map = SwingUtilities.getUIInputMap(root, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); LookAndFeel.loadKeyBindings(map, bindings); } }
public AnimatedToolTip(JLabel label) { super(); this.iconlabel = label; LookAndFeel.installColorsAndFont( iconlabel, "ToolTip.background", "ToolTip.foreground", "ToolTip.font"); iconlabel.setOpaque(true); setLayout(new BorderLayout()); add(iconlabel); }
/** Installs the appropriate <code>Border</code> onto the <code>JRootPane</code>. */ void installBorder(JRootPane root) { int style = root.getWindowDecorationStyle(); if (style == JRootPane.NONE) { LookAndFeel.uninstallBorder(root); } else { root.setBorder(new RootPaneBorder()); } }
private void updateStyle(JTable c) { SynthContext context = getContext(c, ENABLED); SynthStyle oldStyle = style; style = SynthLookAndFeel.updateStyle(context, this); if (style != oldStyle) { context.setComponentState(ENABLED | SELECTED); Color sbg = table.getSelectionBackground(); if (sbg == null || sbg instanceof UIResource) { table.setSelectionBackground(style.getColor(context, ColorType.TEXT_BACKGROUND)); } Color sfg = table.getSelectionForeground(); if (sfg == null || sfg instanceof UIResource) { table.setSelectionForeground(style.getColor(context, ColorType.TEXT_FOREGROUND)); } context.setComponentState(ENABLED); Color gridColor = table.getGridColor(); if (gridColor == null || gridColor instanceof UIResource) { gridColor = (Color) style.get(context, "Table.gridColor"); if (gridColor == null) { gridColor = style.getColor(context, ColorType.FOREGROUND); } table.setGridColor(gridColor == null ? new ColorUIResource(Color.GRAY) : gridColor); } useTableColors = style.getBoolean(context, "Table.rendererUseTableColors", true); useUIBorder = style.getBoolean(context, "Table.rendererUseUIBorder", true); Object rowHeight = style.get(context, "Table.rowHeight"); if (rowHeight != null) { LookAndFeel.installProperty(table, "rowHeight", rowHeight); } boolean showGrid = style.getBoolean(context, "Table.showGrid", true); if (!showGrid) { table.setShowGrid(false); } Dimension d = table.getIntercellSpacing(); // if (d == null || d instanceof UIResource) { if (d != null) { d = (Dimension) style.get(context, "Table.intercellSpacing"); } alternateColor = (Color) style.get(context, "Table.alternateRowColor"); if (d != null) { table.setIntercellSpacing(d); } if (oldStyle != null) { uninstallKeyboardActions(); installKeyboardActions(); } } context.dispose(); }
InputMap getInputMap(int condition) { if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) { Object[] bindings = (Object[]) DefaultLookup.get(optionPane, this, "OptionPane.windowBindings"); if (bindings != null) { return LookAndFeel.makeComponentInputMap(optionPane, bindings); } } return null; }
InputMap createInputMap(int condition) { if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) { Object[] bindings = (Object[]) DefaultLookup.get(desktop, this, "Desktop.windowBindings"); if (bindings != null) { return LookAndFeel.makeComponentInputMap(desktop, bindings); } } return null; }
public static boolean isMacNativeLookAndFeel() { if (AppProperties.OPERATING_SYSTEM.startsWith("mac")) { // $NON-NLS-1$ LookAndFeel laf = javax.swing.UIManager.getLookAndFeel(); if (laf != null && laf.isNativeLookAndFeel()) { return true; } } return false; }