private static void patchGtkDefaults(UIDefaults defaults) { if (!UIUtil.isUnderGTKLookAndFeel()) return; Map<String, Icon> map = ContainerUtil.newHashMap( Arrays.asList( "OptionPane.errorIcon", "OptionPane.informationIcon", "OptionPane.warningIcon", "OptionPane.questionIcon"), Arrays.asList( AllIcons.General.ErrorDialog, AllIcons.General.InformationDialog, AllIcons.General.WarningDialog, AllIcons.General.QuestionDialog)); // GTK+ L&F keeps icons hidden in style SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON); for (String key : map.keySet()) { if (defaults.get(key) != null) continue; Object icon = style == null ? null : style.get(null, key); defaults.put(key, icon instanceof Icon ? icon : map.get(key)); } Color fg = defaults.getColor("Label.foreground"); Color bg = defaults.getColor("Label.background"); if (fg != null && bg != null) { defaults.put("Label.disabledForeground", UIUtil.mix(fg, bg, 0.5)); } }
private static void patchOptionPaneIcons(final UIDefaults defaults) { if (UIUtil.isUnderGTKLookAndFeel() && defaults.get(ourOptionPaneIconKeys[0]) == null) { // GTK+ L&F keeps icons hidden in style final SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON); if (style != null) { for (final String key : ourOptionPaneIconKeys) { final Object icon = style.get(null, key); if (icon != null) defaults.put(key, icon); } } } }
/** * Paint the drop lines, if any. * * @param context the Synth context. * @param g the Graphics context. */ private void paintDropLines(SeaGlassContext context, Graphics g) { JTable.DropLocation loc = table.getDropLocation(); if (loc == null) { return; } Color color = (Color) style.get(context, "Table.dropLineColor"); Color shortColor = (Color) style.get(context, "Table.dropLineShortColor"); if (color == null && shortColor == null) { return; } Rectangle rect; rect = getHDropLineRect(loc); if (rect != null) { int x = rect.x; int w = rect.width; if (color != null) { extendRect(rect, true); g.setColor(color); g.fillRect(rect.x, rect.y, rect.width, rect.height); } if (!loc.isInsertColumn() && shortColor != null) { g.setColor(shortColor); g.fillRect(x, rect.y, w, rect.height); } } rect = getVDropLineRect(loc); if (rect != null) { int y = rect.y; int h = rect.height; if (color != null) { extendRect(rect, false); g.setColor(color); g.fillRect(rect.x, rect.y, rect.width, rect.height); } if (!loc.isInsertRow() && shortColor != null) { g.setColor(shortColor); g.fillRect(rect.x, y, rect.width, h); } } }
private void updateStyle(JToolBar c) { SeaGlassContext context = getContext(c, Region.TOOL_BAR_CONTENT, null, ENABLED); contentStyle = SeaGlassLookAndFeel.updateStyle(context, this); context.getComponent().setOpaque(false); context.dispose(); context = getContext(c, Region.TOOL_BAR_DRAG_WINDOW, null, ENABLED); context.getComponent().setOpaque(false); dragWindowStyle = SeaGlassLookAndFeel.updateStyle(context, this); context.dispose(); context = getContext(c, ENABLED); context.getComponent().setOpaque(false); SynthStyle oldStyle = style; style = SeaGlassLookAndFeel.updateStyle(context, this); if (oldStyle != style) { handleIcon = style.getIcon(context, "ToolBar.handleIcon"); if (oldStyle != null) { uninstallKeyboardActions(); installKeyboardActions(); } } context.dispose(); }
@Override public void installDefaults(SynthContext context) { super.installDefaults(context); if (!context.getRegion().isSubregion()) { context .getComponent() .putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, GTKLookAndFeel.aaTextInfo); } }
@Override protected void uninstallDefaults() { SeaGlassContext context = getContext(toolBar, ENABLED); style.uninstallDefaults(context); context.dispose(); style = null; handleIcon = null; context = getContext(toolBar, Region.TOOL_BAR_CONTENT, contentStyle, ENABLED); contentStyle.uninstallDefaults(context); context.dispose(); contentStyle = null; context = getContext(toolBar, Region.TOOL_BAR_DRAG_WINDOW, dragWindowStyle, ENABLED); dragWindowStyle.uninstallDefaults(context); context.dispose(); dragWindowStyle = null; toolBar.setLayout(null); }
/** @inheritDoc */ @Override protected void uninstallDefaults() { SeaGlassContext context = getContext(getComponent(), ENABLED); JComponent c = getComponent(); c.putClientProperty("caretAspectRatio", null); style.uninstallDefaults(context); context.dispose(); style = null; Object clientProperty = c.getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES); if (clientProperty == localTrue) { c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.FALSE); } super.uninstallDefaults(); }
/** @see javax.swing.plaf.basic.BasicTableUI#uninstallDefaults() */ protected void uninstallDefaults() { table.setDefaultRenderer(Date.class, dateRenderer); table.setDefaultRenderer(Number.class, numberRenderer); table.setDefaultRenderer(Double.class, doubleRender); table.setDefaultRenderer(Float.class, floatRenderer); table.setDefaultRenderer(Icon.class, iconRenderer); table.setDefaultRenderer(ImageIcon.class, imageIconRenderer); table.setDefaultRenderer(Boolean.class, booleanRenderer); table.setDefaultRenderer(Object.class, objectRenderer); if (table.getTransferHandler() instanceof UIResource) { table.setTransferHandler(null); } SeaGlassContext context = getContext(table, ENABLED); style.uninstallDefaults(context); context.dispose(); style = null; }
/** @see javax.swing.plaf.basic.BasicTextUI#uninstallDefaults() */ protected void uninstallDefaults() { JTextComponent c = getComponent(); SeaGlassContext context = getContext(c, ENABLED); // Remove the search border, if present. Border border = c.getBorder(); if (border instanceof TextFieldBorder) { c.setBorder(null); } c.putClientProperty("caretAspectRatio", null); c.removeFocusListener(this); style.uninstallDefaults(context); context.dispose(); style = null; super.uninstallDefaults(); }
/** * Update the style. * * @param c the component. */ private void updateStyle(JTable c) { SeaGlassContext context = getContext(c, ENABLED); SynthStyle oldStyle = style; style = SeaGlassLookAndFeel.updateStyle(context, this); selectionActiveBottomBorderColor = UIManager.getColor("seaGlassTableSelectionActiveBottom"); selectionInactiveBottomBorderColor = UIManager.getColor("seaGlassTableSelectionInactiveBottom"); transparentColor = UIManager.getColor("seaGlassTransparent"); if (style != oldStyle) { table.remove(rendererPane); rendererPane = createCustomCellRendererPane(); table.add(rendererPane); 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); } 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); } table.setOpaque(false); if (alternateColor != null) { table.setShowHorizontalLines(false); } // Make header column extend the width of the viewport (if there is // a viewport). table.getTableHeader().setBorder(createTableHeaderEmptyColumnPainter(table)); setViewPortListeners(table); if (oldStyle != null) { uninstallKeyboardActions(); installKeyboardActions(); } } context.dispose(); }
/** * Sea Glass code to support the search JTextField.variant. * * @param c the JTextField component. * @param context the SeaGlassContext. * @param prefix the control prefix, e.g. "TextField", "FormattedTextField", or "PasswordField". */ private void updateSearchStyle(JTextComponent c, SeaGlassContext context, String prefix) { searchIconWidth = 0; Object o = style.get(context, prefix + ".searchIconWidth"); if (o != null && o instanceof Integer) { searchIconWidth = (Integer) o; } popupIconWidth = 0; o = style.get(context, prefix + ".popupIconWidth"); if (o != null && o instanceof Integer) { popupIconWidth = (Integer) o; } cancelIconWidth = 0; o = style.get(context, prefix + ".cancelIconWidth"); if (o != null && o instanceof Integer) { cancelIconWidth = (Integer) o; } searchLeftInnerMargin = 0; o = style.get(context, prefix + ".searchLeftInnerMargin"); if (o != null && o instanceof Integer) { searchLeftInnerMargin = (Integer) o; } searchRightInnerMargin = 0; o = style.get(context, prefix + ".searchRightInnerMargin"); if (o != null && o instanceof Integer) { searchRightInnerMargin = (Integer) o; } placeholderColor = Color.GRAY; o = style.get(context, "placeholderTextColor"); if (o != null && o instanceof Color) { placeholderColor = (Color) o; } Border border = c.getBorder(); if (border == null || border instanceof UIResource && !(border instanceof TextFieldBorder)) { c.setBorder(createTextFieldBorder(context)); } if (isSearchField.isInState(c)) { o = c.getClientProperty("JTextField.Search.PlaceholderText"); if (o != null && o instanceof String) { placeholderText = (String) o; } else if (placeholderText != null) { placeholderText = null; } o = c.getClientProperty("JTextField.Search.FindAction"); if (o != null && o instanceof ActionListener) { if (findAction == null) { findAction = (ActionListener) o; } } o = c.getClientProperty("JTextField.Search.FindPopup"); if (o != null && o instanceof JPopupMenu) { if (findPopup == null) { findPopup = (JPopupMenu) o; } } o = c.getClientProperty("JTextField.Search.CancelAction"); if (o != null && o instanceof ActionListener) { if (cancelAction == null) { cancelAction = (ActionListener) o; } } installMouseListeners(); } else { placeholderText = null; if (findAction != null) { findAction = null; } if (findPopup != null) { findPopup = null; } if (cancelAction != null) { cancelAction = null; } uninstallMouseListeners(); } }