setUIFont (new javax.swing.plaf.FontUIResource("Serif",Font.ITALIC,12));
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)); } } }
public boolean getScrollableTracksViewportWidth() { boolean bool = super.getScrollableTracksViewportWidth(); if (unwrapped) { Component parent = this.getParent(); ComponentUI ui = this.getUI(); int uiWidth = ui.getPreferredSize(this).width; bool = (parent == null) || (uiWidth < parent.getSize().width); } return bool; }
... dialogTheme.put("Button.background", new ColorUIResource(0, 0, 210)); ... dialogButton.putClientProperty("Nimbus.Overrides", dialogTheme); SwingUtilities.updateComponentTreeUI(dialogButton);
public TristateCheckBox(String text, Icon icon, Boolean initial) { super(text, icon); // Add a listener for when the mouse is pressed super.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { grabFocus(); decorator.nextState(); } }); // Reset the keyboard action map ActionMap map = new ActionMapUIResource(); map.put("pressed", new AbstractAction() { //NOI18N public void actionPerformed(ActionEvent e) { grabFocus(); decorator.nextState(); } }); map.put("released", null); //NOI18N SwingUtilities.replaceUIActionMap(this, map); // set the model to the adapted model decorator = new TristateDecorator(getModel()); setModel(decorator); setState(initial); }
int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), e.getY()); Rectangle bounds = getUI().getTabBounds(DraggableTabbedPane.this, tabNumber); int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), 10);
public void paint(Graphics g) { if (isVisible()) { try { JTextComponent component = getComponent(); Rectangle r = component.getUI().modelToView(component, getDot()); Color c = g.getColor(); g.setColor(component.getBackground()); g.setXORMode(component.getCaretColor()); r.setBounds(r.x, r.y, g.getFontMetrics().charWidth('w'), g.getFontMetrics().getHeight()); g.fillRect(r.x, r.y, r.width, r.height); g.setPaintMode(); g.setColor(c); } catch (BadLocationException e) { e.printStackTrace(); } } }
title = chooser.getUI().getDialogTitle(chooser);
@Override public boolean getScrollableTracksViewportWidth() { return this.getUI().getPreferredSize(this).width <= this.getParent().getSize().width; }
protected void repaintListHighlight(HighlightInfo info) { // Note: We're relying on implementation here, not interface. Yuck... if (info instanceof LayeredHighlightInfoImpl) { LayeredHighlightInfoImpl lhi = (LayeredHighlightInfoImpl)info; if (lhi.width > 0 && lhi.height > 0) { textArea.repaint(lhi.x, lhi.y, lhi.width, lhi.height); } } else { TextUI ui = textArea.getUI(); ui.damageRange(textArea, info.getStartOffset(),info.getEndOffset()); //safeDamageRange(info.p0, info.p1); } }
@Override public void paint(Graphics g) { ui.update(g, this); }
public @Override Dimension getPreferredSize(JComponent c) { if (GraphicsEnvironment.isHeadless()) { // cannot create scratch graphics, so don't bother return super.getPreferredSize(c); } return calcPreferredSize((HtmlRendererImpl) c); }
/** * Returns the default selection background color to use if "default" is * specified in a theme. * * @return The default selection background to use. * @see #getDefaultSelectionFG() */ private static Color getDefaultBG() { Color c = UIManager.getColor("nimbusLightBackground"); if (c==null) { // Don't search for "text", as Nimbus defines that as the text // component "text" color, but Basic LAFs use it for text // component backgrounds! Nimbus also defines TextArea.background // as too dark, not what it actually uses for text area backgrounds c = UIManager.getColor("TextArea.background"); if (c==null) { c = new ColorUIResource(SystemColor.text); } } return c; }
/** * 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 @Override Dimension getPreferredSize() { if (!swingRendering) { if (prefSize == null) { prefSize = getUI().getPreferredSize(this); } return prefSize; } else { return super.getPreferredSize(); } }
/** * Returns the default "selected text" color to use if "default" is * specified in a theme. * * @return The default selection foreground color to use. * @see #getDefaultSelectionBG() */ private static Color getDefaultSelectionFG() { Color c = UIManager.getColor("TextArea.selectionForeground"); if (c==null) { c = UIManager.getColor("textHighlightText"); if (c==null) { c = UIManager.getColor("nimbusSelectedText"); if (c==null) { c = new ColorUIResource(SystemColor.textHighlightText); } } } return c; }
return new FontUIResource(font); } else { return font;
/** * Returns the default selection background color to use if "default" is * specified in a theme. * * @return The default selection background to use. * @see #getDefaultSelectionFG() */ private static Color getDefaultSelectionBG() { Color c = UIManager.getColor("TextArea.selectionBackground"); if (c==null) { c = UIManager.getColor("textHighlight"); if (c==null) { c = UIManager.getColor("nimbusSelectionBackground"); if (c==null) { c = new ColorUIResource(SystemColor.textHighlight); } } } return c; }
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); defaults.put("nimbusBase", new ColorUIResource(210, 0, 210));
/** * Returns the default color for the caret marker. This is a UI * resource so that it is updated if the LookAndFeel is updated, * but not if the user overrides it. * * @return The default color. */ private ColorUIResource getDefaultCaretMarkerColor() { if (RSyntaxUtilities.isLightForeground(getForeground())) { return new ColorUIResource(textArea.getCaretColor()); } return new ColorUIResource(Color.black); }