Draw RoundRectangle2D.Float : Rectangle « 2D Graphics « Java Tutorial






import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.RoundRectangle2D;

public class MainClass extends Frame {
  public static void main(String[] args) {
    (new MainClass()).setVisible(true);
  }

  public MainClass() {
    super("Shape Sampler");
    setSize(400, 550);
  }

  public void paint(Graphics g) {
    RoundRectangle2D rrect;

    Graphics2D g2d = (Graphics2D) g;

    rrect = new RoundRectangle2D.Float(50, 50, 100, 200, 30, 20);
    g2d.draw(rrect);

  }
}








16.41.Rectangle
16.41.1.java.awt.Rectangle
16.41.2.Draw RectangleDraw Rectangle
16.41.3.drawRect (int, int, int, int) to draw a rectangle outline
16.41.4.drawRoundRect (int, int, int, int, int, int) to draw a rounded rectangle outline
16.41.5.Draw a three-dimensional rectangle outline
16.41.6.How do I...Fill shapes?How do I...Fill shapes?
16.41.7.Fill 3D RectangleFill 3D Rectangle
16.41.8.Draw Rectangle with Rectangle2D.Float
16.41.9.Draw RoundRectangle2D.Float
16.41.10.Ractangle with rounded corners drawn using Java 2D Graphics API
16.41.11.Intersection between rectangles
16.41.12.Grow a rectangle
16.41.13.Union two Rectangles
16.41.14.Clips the specified line to the given rectangle.
16.41.15.Returns a point based on (x, y) but constrained to be within the bounds of a given rectangle.
16.41.16.Checks, whether the given rectangle1 fully contains rectangle 2 (even if rectangle 2 has a height or width of zero!).