Java Code Examples for javax.swing.AbstractButton#getHeight()
The following examples show how to use
javax.swing.AbstractButton#getHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicLinkButtonUI.java From orbit-image-analysis with GNU General Public License v3.0 | 6 votes |
protected void paintFocus( Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) { if (b.getParent() instanceof JToolBar) { // Windows doesn't draw the focus rect for buttons in a toolbar. return; } // focus painted same color as text int width = b.getWidth(); int height = b.getHeight(); g.setColor(getFocusColor()); BasicGraphicsUtils.drawDashedRect( g, dashedRectGapX, dashedRectGapY, width - dashedRectGapWidth, height - dashedRectGapHeight); }
Example 2
Source File: WindowsSlidingButtonUI.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){ int width = b.getWidth(); int height = b.getHeight(); g.setColor(getFocusColor()); BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY, width - dashedRectGapWidth, height - dashedRectGapHeight); }
Example 3
Source File: LuckButtonUI.java From littleluck with Apache License 2.0 | 5 votes |
/** * <pre> * 绘制圆角背景, 设置组件偏移实现按钮按下和弹起效果。 * ------------------------------------------------------------------------------------------------- * Draw a rounded background. * set the component offset to achieve the button press and pop-up effect. * </pre> * * @param g Graphics to paint to * @param b AbstractButton painting on * @return paint background return true, otherwise return false. */ protected void paintBg(Graphics g, AbstractButton b) { if(!checkIsPaintBg(b)) { return; } int w = b.getWidth(); int h = b.getHeight(); Graphics2D g2d = (Graphics2D)g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if(b.getModel().isPressed() && b.getModel().isArmed()) { // 点击按钮 // pressed button g2d.setColor(btnColorInfo.getPressedColor()); } else if(b.getModel().isRollover() && b.isRolloverEnabled()) { // 鼠标经过 // mouse enter button g2d.setColor(btnColorInfo.getRollverColor()); } else { g2d.setColor(btnColorInfo.getNormalColor()); } g2d.fillRoundRect(0, 0, w, h, 8, 8); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); }
Example 4
Source File: RapidLookTools.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates the default {@link Shape} for the given button. * * @param b * the button to create the shape for * @return the shape instance */ public static Shape createShapeForButton(AbstractButton b) { int w = b.getWidth(); int h = b.getHeight(); boolean circular = Boolean.parseBoolean(String.valueOf(b.getClientProperty(RapidLookTools.PROPERTY_BUTTON_CIRCLE))); if (circular) { return createCircle(w, h); } else { return new RoundRectangle2D.Double(1, 1, w - 2, h - 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS); } }
Example 5
Source File: RapidLookTools.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates the border {@link Shape} for the given button. * * @param b * the button to create the border shape for * @return the border shape instance */ public static Shape createBorderShapeForButton(AbstractButton b) { int w = b.getWidth(); int h = b.getHeight(); boolean circular = Boolean.parseBoolean(String.valueOf(b.getClientProperty(RapidLookTools.PROPERTY_BUTTON_CIRCLE))); if (circular) { return createCircle(w, h); } else { return new RoundRectangle2D.Double(0, 0, w - 1, h - 1, RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS); } }
Example 6
Source File: BEButtonUI.java From beautyeye with Apache License 2.0 | 5 votes |
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){ //* 由Jack Jiang于2012-10-16日注释掉以下行:目的是修正当JButton处于JToolBar时不能绘制焦点的问题 // if (b.getParent() instanceof JToolBar) { // // Windows doesn't draw the focus rect for buttons in a toolbar. // return; // } //** 被jb2011注释掉:目的是使得在任何情况下都绘制\获得焦点后的虚线框 // if (NLXPStyle.getXP() != null) { // return; // } // focus painted same color as text on Basic?? int width = b.getWidth(); int height = b.getHeight(); g.setColor(getFocusColor()); //** modified by jb2011:绘制虚线方法改成可以设置虚线步进的方法,步进设为2则更好看一点 // BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY, // width - dashedRectGapWidth, height - dashedRectGapHeight); // 绘制虚线框 BEUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY, width - dashedRectGapWidth, height - dashedRectGapHeight); // 绘制虚线框的半透明白色立体阴影(半透明的用处在于若隐若现的效果比纯白要来的柔和的多) g.setColor(new Color(255,255,255,50)); // 立体阴影就是向右下偏移一个像素实现的 BEUtils.drawDashedRect(g, dashedRectGapX+1, dashedRectGapY+1, width - dashedRectGapWidth, height - dashedRectGapHeight); }
Example 7
Source File: BasicLinkButtonUI.java From orbit-image-analysis with GNU General Public License v3.0 | 4 votes |
public void paint(Graphics g, JComponent c) { AbstractButton b = (AbstractButton)c; ButtonModel model = b.getModel(); FontMetrics fm = g.getFontMetrics(); Insets i = c.getInsets(); viewRect.x = i.left; viewRect.y = i.top; viewRect.width = b.getWidth() - (i.right + viewRect.x); viewRect.height = b.getHeight() - (i.bottom + viewRect.y); textRect.x = textRect.y = textRect.width = textRect.height = 0; iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; Font f = c.getFont(); g.setFont(f); // layout the text and icon String text = SwingUtilities.layoutCompoundLabel( c, fm, b.getText(), b.getIcon(), b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, b.getText() == null ? 0 : b.getIconTextGap()); clearTextShiftOffset(); // perform UI specific press action, e.g. Windows L&F shifts text if (model.isArmed() && model.isPressed()) { paintButtonPressed(g, b); } // Paint the Icon if (b.getIcon() != null) { paintIcon(g, c, iconRect); } Composite oldComposite = ((Graphics2D)g).getComposite(); if (model.isRollover()) { ((Graphics2D)g).setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); } if (text != null && !text.equals("")) { View v = (View)c.getClientProperty(BasicHTML.propertyKey); if (v != null) { textRect.x += getTextShiftOffset(); textRect.y += getTextShiftOffset(); v.paint(g, textRect); textRect.x -= getTextShiftOffset(); textRect.y -= getTextShiftOffset(); } else { paintText(g, b, textRect, text); } } if (b.isFocusPainted() && b.hasFocus()) { // paint UI specific focus paintFocus(g, b, viewRect, textRect, iconRect); } ((Graphics2D)g).setComposite(oldComposite); }
Example 8
Source File: ButtonUiStone.java From settlers-remake with MIT License | 4 votes |
@Override public void paint(Graphics g1, JComponent c) { Graphics2D g = DrawHelper.enableAntialiasing(g1); AbstractButton b = (AbstractButton) c; ButtonModel model = b.getModel(); boolean down; if (c instanceof JToggleButton) { down = ((JToggleButton) c).isSelected(); } else { down = model.isArmed() && model.isPressed(); } BufferedImage bg; BufferedImage[] border; float scale = this.scale; if (down) { border = BORDER_DOWN; scale /= 2; bg = backgroundImagePressed; } else { bg = backgroundImage; border = BORDER_NORMAL; } // Draw background g.drawImage(bg, 0, 0, c); BorderHelper.drawBorder(g1, c, border, scale); FontMetrics fm = g.getFontMetrics(); int y = (b.getHeight() - fm.getAscent() - fm.getDescent()) / 2 + fm.getAscent(); int x = textPaddingLeftRight; if (down) { x += 1; y += 1; } g.setFont(c.getFont()); // draw shadow g.setColor(Color.BLACK); g.drawString(b.getText(), x + 1, y + 1); g.setColor(c.getForeground()); g.drawString(b.getText(), x, y); }