public void paintBackground(Graphics g, JComponent c) { if (c.isOpaque()) { if (c.getBackground() instanceof ColorUIResource) { g.setColor(AbstractLookAndFeel.getBackgroundColor()); } else { g.setColor(c.getBackground()); } g.fillRect(0, 0, c.getWidth(), c.getHeight()); } }
public void paintBackground(Graphics g, JComponent c) { if (c.isOpaque()) { if ((c.getBackground().equals(AbstractLookAndFeel.getBackgroundColor())) && (c.getBackground() instanceof ColorUIResource)) { HiFiUtils.fillComponent(g, c); } else { g.setColor(c.getBackground()); g.fillRect(0, 0, c.getWidth(), c.getHeight()); } } }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JComponent c = (JComponent) render.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); c.setBorder(null); JCheckBox lab = new JCheckBox(); ListElement le = (ListElement) value; // if("r1-print".equals(le.getCategory())) // // lab.setIcon(ResourceManager.getIcon(com.kingdee.bos.ctrl.report.forapp.kdnote.client.ui.NoteFileDialogEx.class, "res.r1_print.gif")); // else // // lab.setIcon(ResourceManager.getIcon(com.kingdee.bos.ctrl.report.forapp.kdnote.client.ui.NoteFileDialogEx.class, "res/empty.gif")); lab.setSelected(le.isSelected()); lab.setOpaque(true); lab.setBackground(c.getBackground()); TableLayout tl = TableLayout.splitCol(2); tl.colStyle(0).setWidth(22); tl.colStyle(1).setPriX(1); KDPanel pan = new KDPanel(tl); pan.add(lab, tl.cell(0)); pan.add(c, tl.cell(1)); return pan; }
public void paint(Graphics g, JComponent c) { Dimension s = c.getSize(); if (WindowsMenuItemUI.isVistaPainting()) { int x = 1; Component parent = c.getParent(); if (parent instanceof JComponent) { Object gutterOffsetObject = ((JComponent) parent).getClientProperty(WindowsPopupMenuUI.GUTTER_OFFSET_KEY); if (gutterOffsetObject instanceof Integer) { /* * gutter offset is in parent's coordinates. * See comment in * WindowsPopupMenuUI.getTextOffset(JComponent) */ x = ((Integer) gutterOffsetObject).intValue() - c.getX(); x += WindowsPopupMenuUI.getGutterWidth(); } } Skin skin = XPStyle.getXP().getSkin(c, Part.MP_POPUPSEPARATOR); int skinHeight = skin.getHeight(); int y = (s.height - skinHeight) / 2; skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL); } else { int y = s.height / 2; g.setColor(c.getForeground()); g.drawLine(1, y - 1, s.width - 2, y - 1); g.setColor(c.getBackground()); g.drawLine(1, y, s.width - 2, y); } }
QuickDocInfoPane( @NotNull PsiElement documentationAnchor, @NotNull PsiElement elementUnderMouse, @NotNull JComponent baseDocControl) { myBaseDocControl = baseDocControl; PresentationFactory presentationFactory = new PresentationFactory(); for (AbstractDocumentationTooltipAction action : ourTooltipActions) { Icon icon = action.getTemplatePresentation().getIcon(); Dimension minSize = new Dimension(icon.getIconWidth(), icon.getIconHeight()); myButtons.add( new ActionButton( action, presentationFactory.getPresentation(action), IdeTooltipManager.IDE_TOOLTIP_PLACE, minSize)); action.setDocInfo(documentationAnchor, elementUnderMouse); } Collections.reverse(myButtons); setPreferredSize(baseDocControl.getPreferredSize()); setMaximumSize(baseDocControl.getMaximumSize()); setMinimumSize(baseDocControl.getMinimumSize()); setBackground(baseDocControl.getBackground()); add(baseDocControl, Integer.valueOf(0)); int minWidth = 0; int minHeight = 0; int buttonWidth = 0; for (JComponent button : myButtons) { button.setBorder(null); button.setBackground(baseDocControl.getBackground()); add(button, Integer.valueOf(1)); button.setVisible(false); Dimension preferredSize = button.getPreferredSize(); minWidth += preferredSize.width; minHeight = Math.max(minHeight, preferredSize.height); buttonWidth = Math.max(buttonWidth, preferredSize.width); } myButtonWidth = buttonWidth; int margin = 2; myMinWidth = minWidth + margin * 2 + (myButtons.size() - 1) * BUTTON_HGAP; myMinHeight = minHeight + margin * 2; }
private void drawLine(JComponent c, int x, int y) { _xedit = x; _yedit = y; Graphics g = c.getGraphics(); g.setColor(Color.BLACK); g.setXORMode(c.getBackground()); g.drawLine(_xdown, _ydown, _xedit, _yedit); g.dispose(); }
public void update(Graphics g, JComponent c) { if (c.isOpaque()) { g.setColor(c.getBackground()); g.fillRect(0, 0, c.getWidth(), c.getHeight()); if (isToolBarComboBox(c)) { c.setOpaque(false); } } paint(g, c); }
@NotNull private JComponent createHintComponent( @NotNull String text, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages, @NotNull final FindUsagesOptions options) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = new Runnable() { @Override public void run() { searchEverywhere(options, handler, editor, popupPosition, maxUsages); } }; super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }
public static void installColors( final JComponent comp, final String background, final String foreground) { Color foregroundColor = comp.getForeground(); if (Utilities.isUIResource(foregroundColor)) { comp.setForeground(UIManager.getColor(foreground)); } Color backgroundColor = comp.getBackground(); if (Utilities.isUIResource(backgroundColor)) { comp.setBackground(UIManager.getColor(background)); } }
public void update(Graphics g, JComponent c) { if (c.isOpaque()) { g.setColor(c.getBackground()); g.fillRect(0, 0, c.getWidth(), c.getHeight()); if (is3D()) { Rectangle bounds = new Rectangle(0, 0, c.getWidth(), c.getHeight()); boolean isHorizontal = ((JToolBar) c).getOrientation() == SwingConstants.HORIZONTAL; PlasticUtils.addLight3DEffekt(g, bounds, isHorizontal); } } paint(g, c); }
@Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { final Component result = super.prepareRenderer(renderer, row, column); final boolean selected = myExpandableItemsHandler.getExpandedItems().contains(new TableCell(row, column)); // Fix GTK background if (UIUtil.isUnderGTKLookAndFeel()) { UIUtil.changeBackGround(this, UIUtil.getTreeTextBackground()); } if (isTableDecorationSupported() && isStriped() && result instanceof JComponent) { final Color bg = row % 2 == 1 ? getBackground() : DECORATED_ROW_BG_COLOR; final JComponent c = (JComponent) result; final boolean cellSelected = isCellSelected(row, column); if (!cellSelected || (!hasFocus() && !getSelectionBackground().equals(c.getBackground()))) { c.setOpaque(true); c.setBackground(bg); for (Component child : c.getComponents()) { child.setBackground(bg); } } } if (!selected) return result; return new JComponent() { { add(result); setOpaque(false); setLayout( new AbstractLayoutManager() { @Override public Dimension preferredLayoutSize(Container parent) { return result.getPreferredSize(); } @Override public void layoutContainer(Container parent) { Dimension size = parent.getSize(); Insets i = parent.getInsets(); Dimension pref = result.getPreferredSize(); result.setBounds( i.left, i.top, Math.max(pref.width, size.width - i.left - i.right), size.height - i.top - i.bottom); } }); } }; }
@Override public Color getColor(SynthContext context, ColorType type) { JComponent c = context.getComponent(); Region id = context.getRegion(); int state = context.getComponentState(); if (c.getName() == "Table.cellRenderer") { if (type == ColorType.BACKGROUND) { return c.getBackground(); } if (type == ColorType.FOREGROUND) { return c.getForeground(); } } if (id == Region.LABEL && type == ColorType.TEXT_FOREGROUND) { type = ColorType.FOREGROUND; } // For the enabled state, prefer the widget's colors if (!id.isSubregion() && (state & SynthConstants.ENABLED) != 0) { if (type == ColorType.BACKGROUND) { return c.getBackground(); } else if (type == ColorType.FOREGROUND) { return c.getForeground(); } else if (type == ColorType.TEXT_FOREGROUND) { // If getForeground returns a non-UIResource it means the // developer has explicitly set the foreground, use it over // that of TEXT_FOREGROUND as that is typically the expected // behavior. Color color = c.getForeground(); if (color != null && !(color instanceof UIResource)) { return color; } } } return getColorForState(context, type); }
/** * Returns the color for the specified state. * * @param context SynthContext identifying requestor * @param state to get the color for * @param type of the color * @return Color to render with */ Color getGTKColor(SynthContext context, int state, ColorType type) { if (context != null) { JComponent c = context.getComponent(); Region id = context.getRegion(); state = GTKLookAndFeel.synthStateToGTKState(id, state); if (!id.isSubregion() && (state & SynthConstants.ENABLED) != 0) { if (type == ColorType.BACKGROUND || type == ColorType.TEXT_BACKGROUND) { Color bg = c.getBackground(); if (!(bg instanceof UIResource)) { return bg; } } else if (type == ColorType.FOREGROUND || type == ColorType.TEXT_FOREGROUND) { Color fg = c.getForeground(); if (!(fg instanceof UIResource)) { return fg; } } } } return getStyleSpecificColor(context, state, type); }
/** * If necessary paints the background of the component, then invokes <code>paint</code>. * * @param g Graphics to paint to * @param c JComponent painting on * @throws NullPointerException if <code>g</code> or <code>c</code> is null * @see javax.swing.plaf.ComponentUI#update * @see javax.swing.plaf.ComponentUI#paint * @since 1.5 */ public void update(Graphics g, JComponent c) { AbstractButton button = (AbstractButton) c; if ((c.getBackground() instanceof UIResource) && button.isContentAreaFilled() && c.isEnabled()) { ButtonModel model = button.getModel(); if (!MetalUtils.isToolBarButton(c)) { if (!model.isArmed() && !model.isPressed() && MetalUtils.drawGradient( c, g, "Button.gradient", 0, 0, c.getWidth(), c.getHeight(), true)) { paint(g, c); return; } } else if (model.isRollover() && MetalUtils.drawGradient( c, g, "Button.gradient", 0, 0, c.getWidth(), c.getHeight(), true)) { paint(g, c); return; } } super.update(g, c); }
/** * This method is not being used to paint menu item since 6.0 This code left for compatibility * only. Do not use or override it, this will not cause any visible effect. */ public static void paintMenuItem( Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem b = (JMenuItem) c; ButtonModel model = b.getModel(); Dimension size = b.getSize(); Insets i = c.getInsets(); Rectangle viewRect = new Rectangle(size); viewRect.x += i.left; viewRect.y += i.top; viewRect.width -= (i.right + viewRect.x); viewRect.height -= (i.bottom + viewRect.y); Rectangle iconRect = new Rectangle(); Rectangle textRect = new Rectangle(); Rectangle acceleratorRect = new Rectangle(); Rectangle checkRect = new Rectangle(); Rectangle arrowRect = new Rectangle(); Font holdf = g.getFont(); Font f = c.getFont(); g.setFont(f); FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f); FontMetrics fmAccel = SwingUtilities2.getFontMetrics(c, g, UIManager.getFont("MenuItem.acceleratorFont")); if (c.isOpaque()) { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(background); } else { g.setColor(c.getBackground()); } g.fillRect(0, 0, size.width, size.height); } // get Accelerator text KeyStroke accelerator = b.getAccelerator(); String acceleratorText = ""; if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { acceleratorText = KeyEvent.getKeyModifiersText(modifiers); acceleratorText += "+"; } acceleratorText += KeyEvent.getKeyText(accelerator.getKeyCode()); } // layout the text and icon String text = layoutMenuItem( c, fm, b.getText(), fmAccel, acceleratorText, b.getIcon(), checkIcon, arrowIcon, b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, acceleratorRect, checkRect, arrowRect, b.getText() == null ? 0 : defaultTextIconGap, defaultTextIconGap); // Paint the Check Color holdc = g.getColor(); if (checkIcon != null) { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) g.setColor(foreground); checkIcon.paintIcon(c, g, checkRect.x, checkRect.y); g.setColor(holdc); } // Paint the Icon if (b.getIcon() != null) { Icon icon; if (!model.isEnabled()) { icon = b.getDisabledIcon(); } else if (model.isPressed() && model.isArmed()) { icon = b.getPressedIcon(); if (icon == null) { // Use default icon icon = b.getIcon(); } } else { icon = b.getIcon(); } if (icon != null) { icon.paintIcon(c, g, iconRect.x, iconRect.y); } } // Draw the Text if (text != null && !text.equals("")) { // Once BasicHTML becomes public, use BasicHTML.propertyKey // instead of the hardcoded string below! View v = (View) c.getClientProperty("html"); if (v != null) { v.paint(g, textRect); } else { int mnemIndex = b.getDisplayedMnemonicIndex(); if (!model.isEnabled()) { // *** paint the text disabled g.setColor(b.getBackground().brighter()); SwingUtilities2.drawStringUnderlineCharAt( b, g, text, mnemIndex, textRect.x, textRect.y + fmAccel.getAscent()); g.setColor(b.getBackground().darker()); SwingUtilities2.drawStringUnderlineCharAt( b, g, text, mnemIndex, textRect.x - 1, textRect.y + fmAccel.getAscent() - 1); } else { // *** paint the text normally if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(foreground); } else { g.setColor(b.getForeground()); } SwingUtilities2.drawStringUnderlineCharAt( b, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); } } } // Draw the Accelerator Text if (acceleratorText != null && !acceleratorText.equals("")) { // Get the maxAccWidth from the parent to calculate the offset. int accOffset = 0; Container parent = b.getParent(); if (parent != null && parent instanceof JComponent) { JComponent p = (JComponent) parent; Integer maxValueInt = (Integer) p.getClientProperty(MotifGraphicsUtils.MAX_ACC_WIDTH); int maxValue = maxValueInt != null ? maxValueInt.intValue() : acceleratorRect.width; // Calculate the offset, with which the accelerator texts will be drawn with. accOffset = maxValue - acceleratorRect.width; } g.setFont(UIManager.getFont("MenuItem.acceleratorFont")); if (!model.isEnabled()) { // *** paint the acceleratorText disabled g.setColor(b.getBackground().brighter()); SwingUtilities2.drawString( c, g, acceleratorText, acceleratorRect.x - accOffset, acceleratorRect.y + fm.getAscent()); g.setColor(b.getBackground().darker()); SwingUtilities2.drawString( c, g, acceleratorText, acceleratorRect.x - accOffset - 1, acceleratorRect.y + fm.getAscent() - 1); } else { // *** paint the acceleratorText normally if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(foreground); } else { g.setColor(b.getForeground()); } SwingUtilities2.drawString( c, g, acceleratorText, acceleratorRect.x - accOffset, acceleratorRect.y + fmAccel.getAscent()); } } // Paint the Arrow if (arrowIcon != null) { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) g.setColor(foreground); if (!(b.getParent() instanceof JMenuBar)) arrowIcon.paintIcon(c, g, arrowRect.x, arrowRect.y); } g.setColor(holdc); g.setFont(holdf); }
protected void paintBackground( Graphics g, int x, int y, int w, int h, boolean horizontal, JComponent component) { Graphics2D g2d = (Graphics2D) g.create(); CEclipseBorder ec = null; Insets ins = getOutsideInsets(); x = ins.left; y = ins.top; if (getOrientation().isHorizontal()) { w -= ins.left + ins.right; h -= ins.top + ins.bottom; } else { w -= ins.top + ins.bottom; h -= ins.left + ins.right; } if (component.getBorder() instanceof CompoundBorder) { CompoundBorder cb = (CompoundBorder) component.getBorder(); CompoundBorder bb = (CompoundBorder) cb.getInsideBorder(); ec = (CEclipseBorder) bb.getOutsideBorder(); } if (w > 0 && h > 0) { if (glassStrip != null) { BufferedImage im = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D gg = im.createGraphics(); gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); gg.setColor(component.getBackground()); if (ec != null) { gg.fill(ec.createShape(0, 0, w, h, ec.getCornerRadius())); } else { gg.fillRect(0, 0, w, h); } if (!isSelected()) { gg.setComposite(AlphaComposite.SrcIn); } else { gg.setComposite(AlphaComposite.SrcAtop); } try { glass.Render2Graphics(new Dimension(w, h), gg, glassStrip, true); } catch (Exception e) { glass.Render2Graphics(new Dimension(w, h), gg, CGlassFactory.VALUE_STEEL, true); } gg.dispose(); if (!getOrientation().isHorizontal()) { AffineTransform atTrans = AffineTransform.getTranslateInstance(x /* + h */, y + w); atTrans.concatenate(COutlineHelper.tRot90CCW); g2d.drawImage(im, atTrans, null); } else { g2d.drawImage(im, x, y, null); } } g2d.dispose(); } }
public static void main(String args[]) { JComponent ch = new JComponent() {}; ch.getAccessibleContext(); ch.isFocusTraversable(); ch.setEnabled(false); ch.setEnabled(true); ch.requestFocus(); ch.requestFocusInWindow(); ch.getPreferredSize(); ch.getMaximumSize(); ch.getMinimumSize(); ch.contains(1, 2); Component c1 = ch.add(new Component() {}); Component c2 = ch.add(new Component() {}); Component c3 = ch.add(new Component() {}); Insets ins = ch.getInsets(); ch.getAlignmentY(); ch.getAlignmentX(); ch.getGraphics(); ch.setVisible(false); ch.setVisible(true); ch.setForeground(Color.red); ch.setBackground(Color.red); for (String font : Toolkit.getDefaultToolkit().getFontList()) { for (int j = 8; j < 17; j++) { Font f1 = new Font(font, Font.PLAIN, j); Font f2 = new Font(font, Font.BOLD, j); Font f3 = new Font(font, Font.ITALIC, j); Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); ch.setFont(f1); ch.setFont(f2); ch.setFont(f3); ch.setFont(f4); ch.getFontMetrics(f1); ch.getFontMetrics(f2); ch.getFontMetrics(f3); ch.getFontMetrics(f4); } } ch.enable(); ch.disable(); ch.reshape(10, 10, 10, 10); ch.getBounds(new Rectangle(1, 1, 1, 1)); ch.getSize(new Dimension(1, 2)); ch.getLocation(new Point(1, 2)); ch.getX(); ch.getY(); ch.getWidth(); ch.getHeight(); ch.isOpaque(); ch.isValidateRoot(); ch.isOptimizedDrawingEnabled(); ch.isDoubleBuffered(); ch.getComponentCount(); ch.countComponents(); ch.getComponent(1); ch.getComponent(2); Component[] cs = ch.getComponents(); ch.getLayout(); ch.setLayout(new FlowLayout()); ch.doLayout(); ch.layout(); ch.invalidate(); ch.validate(); ch.remove(0); ch.remove(c2); ch.removeAll(); ch.preferredSize(); ch.minimumSize(); ch.getComponentAt(1, 2); ch.locate(1, 2); ch.getComponentAt(new Point(1, 2)); ch.isFocusCycleRoot(new Container()); ch.transferFocusBackward(); ch.setName("goober"); ch.getName(); ch.getParent(); ch.getGraphicsConfiguration(); ch.getTreeLock(); ch.getToolkit(); ch.isValid(); ch.isDisplayable(); ch.isVisible(); ch.isShowing(); ch.isEnabled(); ch.enable(false); ch.enable(true); ch.enableInputMethods(false); ch.enableInputMethods(true); ch.show(); ch.show(false); ch.show(true); ch.hide(); ch.getForeground(); ch.isForegroundSet(); ch.getBackground(); ch.isBackgroundSet(); ch.getFont(); ch.isFontSet(); Container c = new Container(); c.add(ch); ch.getLocale(); for (Locale locale : Locale.getAvailableLocales()) ch.setLocale(locale); ch.getColorModel(); ch.getLocation(); boolean exceptions = false; try { ch.getLocationOnScreen(); } catch (IllegalComponentStateException e) { exceptions = true; } if (!exceptions) throw new RuntimeException("IllegalComponentStateException did not occur when expected"); ch.location(); ch.setLocation(1, 2); ch.move(1, 2); ch.setLocation(new Point(1, 2)); ch.getSize(); ch.size(); ch.setSize(1, 32); ch.resize(1, 32); ch.setSize(new Dimension(1, 32)); ch.resize(new Dimension(1, 32)); ch.getBounds(); ch.bounds(); ch.setBounds(10, 10, 10, 10); ch.setBounds(new Rectangle(10, 10, 10, 10)); ch.isLightweight(); ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); ch.getCursor(); ch.isCursorSet(); ch.inside(1, 2); ch.contains(new Point(1, 2)); ch.isFocusable(); ch.setFocusable(true); ch.setFocusable(false); ch.transferFocus(); ch.getFocusCycleRootAncestor(); ch.nextFocus(); ch.transferFocusUpCycle(); ch.hasFocus(); ch.isFocusOwner(); ch.toString(); ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); ch.setComponentOrientation(ComponentOrientation.UNKNOWN); ch.getComponentOrientation(); }
public void paint(final Graphics g, final JComponent c) { final AnchoredButton button = (AnchoredButton) c; final String text = button.getText(); final Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon(); if ((icon == null) && (text == null)) { return; } final FontMetrics fm = button.getFontMetrics(button.getFont()); ourViewInsets = c.getInsets(ourViewInsets); ourViewRect.x = ourViewInsets.left; ourViewRect.y = ourViewInsets.top; final ToolWindowAnchor anchor = button.getAnchor(); // Use inverted height & width if (ToolWindowAnchor.RIGHT == anchor || ToolWindowAnchor.LEFT == anchor) { ourViewRect.height = c.getWidth() - (ourViewInsets.left + ourViewInsets.right); ourViewRect.width = c.getHeight() - (ourViewInsets.top + ourViewInsets.bottom); } else { ourViewRect.height = c.getHeight() - (ourViewInsets.left + ourViewInsets.right); ourViewRect.width = c.getWidth() - (ourViewInsets.top + ourViewInsets.bottom); } ourIconRect.x = ourIconRect.y = ourIconRect.width = ourIconRect.height = 0; ourTextRect.x = ourTextRect.y = ourTextRect.width = ourTextRect.height = 0; final String clippedText = SwingUtilities.layoutCompoundLabel( c, fm, text, icon, button.getVerticalAlignment(), button.getHorizontalAlignment(), button.getVerticalTextPosition(), button.getHorizontalTextPosition(), ourViewRect, ourIconRect, ourTextRect, button.getText() == null ? 0 : button.getIconTextGap()); // Paint button's background final Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); final ButtonModel model = button.getModel(); final Color background = button.getBackground(); Color toBorder = model.isRollover() ? new Color(0, 0, 0, 50) : null; final boolean vertical = anchor == ToolWindowAnchor.LEFT || anchor == ToolWindowAnchor.RIGHT; if (model.isArmed() && model.isPressed() || model.isSelected()) { g2.setColor(new Color(0, 0, 0, 30)); g2.fillRect(3, 3, button.getWidth() - (vertical ? 6 : 5), button.getHeight() - 6); g2.setColor(new Color(0, 0, 0, 120)); g2.drawLine(2, 2, 3 + button.getWidth() - (vertical ? 7 : 6), 2); g2.drawLine(2, 3, 2, 3 + button.getHeight() - 7); g2.setColor(new Color(0, 0, 0, 40)); g2.drawRect(3, 3, button.getWidth() - (vertical ? 7 : 6), button.getHeight() - 7); g2.setColor(new Color(255, 255, 255, 110)); g2.drawLine( 3, button.getHeight() - 3, 3 + button.getWidth() - (vertical ? 6 : 5), button.getHeight() - 3); g2.drawLine( 3 + button.getWidth() - (vertical ? 6 : 5), 2, 3 + button.getWidth() - (vertical ? 6 : 5), 3 + button.getHeight() - 7); toBorder = null; } if (toBorder != null) { g.setColor(toBorder); g.drawRect(2, 2, button.getWidth() - (vertical ? 6 : 5), button.getHeight() - 6); } AffineTransform tr = null; if (ToolWindowAnchor.RIGHT == anchor || ToolWindowAnchor.LEFT == anchor) { tr = g2.getTransform(); if (ToolWindowAnchor.RIGHT == anchor) { if (icon != null) { // do not rotate icon icon.paintIcon(c, g2, ourIconRect.y, ourIconRect.x); } g2.rotate(Math.PI / 2); g2.translate(0, -c.getWidth()); } else { if (icon != null) { // do not rotate icon icon.paintIcon( c, g2, ourIconRect.y, c.getHeight() - ourIconRect.x - icon.getIconHeight()); } g2.rotate(-Math.PI / 2); g2.translate(-c.getHeight(), 0); } } else { if (icon != null) { icon.paintIcon(c, g2, ourIconRect.x, ourIconRect.y); } } // paint text if (text != null) { if (model.isEnabled()) { if (model.isArmed() && model.isPressed() || model.isSelected()) { g.setColor(background); } else { g.setColor(button.getForeground()); } } else { g.setColor(background.darker()); } /* Draw the Text */ if (model.isEnabled()) { /** * paint the text normally */ g.setColor(button.getForeground()); BasicGraphicsUtils.drawString( g, clippedText, button.getMnemonic2(), ourTextRect.x, ourTextRect.y + fm.getAscent()); } else { /** * paint the text disabled ** */ if (model.isSelected()) { g.setColor(c.getBackground()); } else { g.setColor(getDisabledTextColor()); } BasicGraphicsUtils.drawString( g, clippedText, button.getMnemonic2(), ourTextRect.x, ourTextRect.y + fm.getAscent()); } } if (ToolWindowAnchor.RIGHT == anchor || ToolWindowAnchor.LEFT == anchor) { g2.setTransform(tr); } }