public void drawNode(Graphics g, int x, int y, String label, int style) { Color old=g.getColor(); int width, height; width=fm.stringWidth(label) + 10; height=fm.getHeight() + 5; g.setColor(node_color); g.fillRect(x, y, width, height); g.setColor(old); g.drawString(label, x + 5, y + 15); g.drawRoundRect(x - 1, y - 1, width + 1, height + 1, 10, 10); if(style == CheckStyle) { g.drawRoundRect(x - 2, y - 2, width + 2, height + 2, 10, 10); g.drawRoundRect(x - 3, y - 3, width + 3, height + 3, 10, 10); } }
RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(color); g.drawRoundRect(x, y, width, height, MARGIN, MARGIN);
g2d.drawRoundRect(3, 3, getWidth()-4, getHeight()-4, archH, archH);
private static class RoundedBorder implements Border { private int radius; RoundedBorder(int radius) { this.radius = radius; } public Insets getBorderInsets(Component c) { return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius); } public boolean isBorderOpaque() { return true; } public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { g.drawRoundRect(x, y, width-1, height-1, radius, radius); } }
g.drawRoundRect(random.nextInt(width), random.nextInt(height), random.nextInt(50), random.nextInt(50), random.nextInt(50), random.nextInt(50)); case 2://方 for (int i = 0; i < random.nextInt(10); i++) { g.drawRoundRect(random.nextInt(width), random.nextInt(height), random.nextInt(50), random.nextInt(50), random.nextInt(50), random.nextInt(50));
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); } }
g.drawImage(icon, 0, 0, p); g.setColor(Color.RED); g.drawRoundRect( 0, 0, iconPressed.getWidth(p)-1, iconPressed.getHeight(p)-1,
public boolean isBorderOpaque() { return false; } public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { // Stroke width? g.drawRoundRect(x,y,width-1,height-1,radius,radius); }
protected void paintButtonPressed(Graphics g, AbstractButton b) { g.setColor(Color.BLUE); g.drawRoundRect(viewRect.x + 2, viewRect.y + 2, viewRect.width - 5, viewRect.height - 5, 5, 5); g.drawRoundRect(viewRect.x, viewRect.y, viewRect.width - 1, viewRect.height - 1, 5, 5); }
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); Graphics g = image.getGraphics(); // Pass this graphics object to your application to perform the drawing g.setColor(Color.red); g.drawRoundRect(10, 10, 20, 20, 5, 5); // save it to disk ImageIO.write(image, "png", new File("test.png"));
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Color oldColor = g.getColor(); int i; g.setColor(lineColor); for (i = 0; i < thickness; i++) { if (!roundedCorners) g.drawRect(x + i, y + i, width - i - i - 1, height - i - i - 1); else g.drawRoundRect(x + i, y + i, width - i - i - 1, height - i - i - 1, arcWidth, arcHeight); } g.setColor(oldColor); }
@Override protected void paintComponent(Graphics g) { g.setColor(new Color(5,5,5)); g.fillRect(0,0,100,100); g.setColor(Color.Green); g.drawRoundRect(30,30,20,20,5,5); g.setColor(new Color(200,200,200)); g.setFont(new Font("Eras Bold ITC", Font.BOLD, 150)); g.drawString("hi",25,25); }
// 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 drawRoundedRectangle( final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight, final Color color) { useColor(color); graphics.drawRoundRect(x, y, width - 1, height - 1, arcWidth, arcHeight); }
public void drawRoundedRectangle( final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight, final Color color) { useColor(color); graphics.drawRoundRect(x, y, width - 1, height - 1, arcWidth, arcHeight); }
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); }
public void paint(Graphics _g) { BuLib.setAntialiasing(this, _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 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); }
@Override protected void paintComponent(Graphics g) { g.setColor(Color.WHITE); g.drawRect(0,0,getWidth(),getHeight()); Graphics2D g2 = (Graphics2D)g; g2.setPaint(new GradientPaint(0,0,Color.WHITE,getWidth()-1,getHeight()-1,Color.LIGHT_GRAY)); g2.fillRect(0, 0, getWidth()-1,getHeight()-1); paintChildren(g); g.setColor(Color.GRAY); g.drawRoundRect(0,0,getWidth()-1,getHeight()-1,5,5); }