Graphics g = bi.createGraphics(); g.setColor(new Color(255, 255, 255, 128)); g.fillRoundRect( 0, 0,
private void createShadowPicture(BufferedImage image) { int width = image.getWidth(); int height = image.getHeight(); int extra = 0; if (System.getProperty("os.name").equalsIgnoreCase("Windows XP")) { extra = 14; // Only create shadow if Windows XP (avoids double shadow in Mac OS; not tested for other OSes) } setSize(new Dimension(width + extra, height + extra)); setLocationRelativeTo(null); Rectangle windowRect = getBounds(); splash = new BufferedImage(width + extra, height + extra, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = (Graphics2D) splash.getGraphics(); try { Robot robot = new Robot(getGraphicsConfiguration().getDevice()); BufferedImage capture = robot.createScreenCapture(new Rectangle(windowRect.x, windowRect.y, windowRect.width + extra, windowRect.height + extra)); g2.drawImage(capture, null, 0, 0); } catch (AWTException e) { } BufferedImage shadow = new BufferedImage(width + extra, height + extra, BufferedImage.TYPE_INT_ARGB); Graphics g = shadow.getGraphics(); g.setColor(new Color(0.0f, 0.0f, 0.0f, 0.3f)); g.fillRoundRect(6, 6, width, height, 12, 12); g2.drawImage(shadow, getBlurOp(7), 0, 0); g2.drawImage(image, 0, 0, this); }
g2d.fillRoundRect(3, 3, getWidth()-4, getHeight()-4, archH, archH); setForeground(Color.black);
protected void paintComponent( Graphics g ) { g.setColor( getBackground() ); g.fillRoundRect( 1, 1, getWidth()-2 - 1, getHeight()-2 ,2 ,2 ); Graphics2D g2 = (Graphics2D)g;
public void paintInternalFrameBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { g.setColor(new Color(50, 50, 50, 100)); g.fillRoundRect(x, y, w, h, 5, 5); } };
public void paintIcon(Component c, Graphics g, int x, int y) { ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.DARK_GRAY); g.fillRoundRect(x, y, SIZE, SIZE, 10, 10); g.drawImage(image, (SIZE - image.getWidth()) / 2 + x, (SIZE - image.getHeight()) / 2 + y, null); }
protected void paintMatchedBracketImpl(Graphics g, RSyntaxTextArea rsta, Rectangle r) { // We must add "-1" to the height because otherwise we'll paint below // the region that gets invalidated. if (rsta.getAnimateBracketMatching()) { Color bg = rsta.getMatchedBracketBGColor(); final int arcWH = 5; if (bg!=null) { g.setColor(bg); g.fillRoundRect(r.x,r.y, r.width,r.height-1, arcWH, arcWH); } g.setColor(rsta.getMatchedBracketBorderColor()); g.drawRoundRect(r.x,r.y, r.width,r.height-1, arcWH, arcWH); } else { Color bg = rsta.getMatchedBracketBGColor(); if (bg!=null) { g.setColor(bg); g.fillRect(r.x,r.y, r.width,r.height-1); } g.setColor(rsta.getMatchedBracketBorderColor()); g.drawRect(r.x,r.y, r.width,r.height-1); } }
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(Color.DARK_GRAY); g2d.fillRoundRect(getWidth()/2-100, getHeight()/2-15, 200, 30, 30, 30); g2d.setColor(Color.WHITE); g2d.drawString("Loading image...", getWidth()/2 - 45, getHeight()/2 + 3 );
public void fillRoundRect (Graphics _g, int _x, int _y, int _w, int _h, int _rh, int _rv) { _g.fillRoundRect(_x,_y,_w,_h,_rh,_rv); }
paintComponent(Graphics g) { //If you want more: Graphics2D g2 = (Graphics2D) g; Rect rect = getBounds(); g.setColor(Color.BLACK); g.fillRect(rect.x, rect,y, rect.width, rect.height); rect.grow(-4, -4); g.setColor(getBackground()); g.fillRoundRect(rect.x, rect,y, rect.width, rect.height, 5, 5); }
public void paintIcon(Component c, Graphics g, int x, int y) { ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.DARK_GRAY); g.fillRoundRect(x, y, SIZE, SIZE, 10, 10); g.drawImage(image, (SIZE - image.getWidth()) / 2 + x, (SIZE - image.getHeight()) / 2 + y, null); }
class GridPanel extends JPanel { GridPanel() { super(); } @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.decode("#0232ac")); g.fillRoundRect(100, 50, 300, 600, 50, 50); g.setColor(Color.white); g.drawString("TitleonRect", 220, 80); } }
private void paintBackground (Graphics g, JComponent c) { g.setColor (c.getBackground ()); g.fillRoundRect (0, 0, c.getWidth (), c.getHeight (), 7, 7); } }
// Draw rectangles import java.awt.*; import java.applet.*; public class Rectangles extends Applet { public void paint(Graphics g) { g.drawRect(10, 10, 60, 50); g.fillRect(100, 10, 60, 50); g.drawRoundRect(190, 10, 60, 50, 15, 15); g.fillRoundRect(70, 90, 140, 100, 30, 40); } }
public void paintCommandBarBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { g.setColor(UIDefaultsLookup.getColor("CommandBar.background")); g.fillRoundRect(rect.x, rect.y, rect.width, rect.height, 2, 2); }
public void paint(Graphics _g) { super.paint(_g); if(drop_) { Rectangle r=getDropRect(); _g.setColor(new Color(255,128,0,64)); _g.fillRoundRect(r.x,r.y,r.width,r.height,9,9); _g.setColor(new Color(255,128,0)); _g.drawRoundRect(r.x,r.y,r.width-1,r.height-1,9,9); } }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); int w = getWidth(); int h = getHeight(); g.setColor(Color.WHITE); g.fillRoundRect(0, 0, w - 1, h - 1, 12, 12); g.setColor(Color.GRAY); g.drawRoundRect(0, 0, w - 1, h - 1, 12, 12); }
@Override public void paintComponent(@Nonnull final Graphics g) { final Dimension size = this.getSize(); g.setColor(this.getBackground()); size.width--; size.height--; final int radius = size.height / 2; g.fillRoundRect(0, 0, size.width, size.height, radius, radius); g.setColor(this.getBackground().darker().darker()); g.drawRoundRect(0, 0, size.width, size.height, radius, radius); super.paintComponent(g); }
protected void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; Composite orgComposite = g2.getComposite(); Color orgColor = g2.getColor(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.70f)); Object o = JideSwingUtilities.setupShapeAntialiasing(g); g2.setColor(getBackground()); g.fillRoundRect(1, 1, getWidth() - 2, getHeight() - 2, 1, 1); JideSwingUtilities.restoreShapeAntialiasing(g, o); g2.setColor(orgColor); g2.setComposite(orgComposite); super.paintComponent(g); } }
@Override public void paint (final Graphics g) { final Graphics2D g2 = (Graphics2D)g; final Object antiAliasingSave = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(getBackground()); g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, radius, radius); paintComponents(g); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAliasingSave); } }