Example usage for java.awt Graphics drawRect

List of usage examples for java.awt Graphics drawRect

Introduction

In this page you can find the example usage for java.awt Graphics drawRect.

Prototype

public void drawRect(int x, int y, int width, int height) 

Source Link

Document

Draws the outline of the specified rectangle.

Usage

From source file:MainClass.java

public void paint(Graphics g) {
    g.drawRect(10, 10, 60, 50);
    g.fillRect(100, 10, 60, 50);//from  w  w  w.  ja v a  2  s.c  o m
    g.drawRoundRect(190, 10, 60, 50, 15, 15);
    g.fillRoundRect(70, 90, 140, 100, 30, 40);
}

From source file:intersection.java

public void paint(Graphics g) {
    g.drawRect(r.x, r.y, r.width, r.height);
    g.drawRect(r1.x, r1.y, r1.width, r1.height);
    Rectangle r2 = r.intersection(r1);
    System.out.println(r2);// ww w.  j a va  2  s.  c  o  m
    g.fillRect(r2.x, r2.y, r2.width, r2.height);
}

From source file:Main.java

public void paint(Graphics g) {
    g.setColor(Color.red);
    g.drawRect(0, 0, 100, 100);
    g.clipRect(25, 25, 50, 50);
    g.drawLine(0, 100, 100, 0);
}

From source file:Main.java

public void paint(Graphics g) {
    g.setColor(Color.red);// www  . j  a  v a  2s .c  om
    Graphics clippedGraphics = g.create();
    clippedGraphics.drawRect(0, 0, 100, 100);
    clippedGraphics.clipRect(25, 25, 50, 50);
    clippedGraphics.drawLine(0, 0, 100, 100);
    clippedGraphics.dispose();
    clippedGraphics = null;
    g.drawLine(0, 100, 100, 0);
}

From source file:Main.java

public void paint(Graphics g) {
    g.setColor(Color.red);/*from   w w w.j a  v a  2s. c  om*/
    Graphics clippedGraphics = g.create();
    clippedGraphics.drawRect(0, 0, 100, 100);
    clippedGraphics.clipRect(25, 25, 50, 50);
    clippedGraphics.drawLine(0, 0, 100, 100);
    clippedGraphics.finalize();
    clippedGraphics = null;
    g.drawLine(0, 100, 100, 0);
}

From source file:MainClass.java

public void paint(Graphics g) {
    g.setColor(Color.red);

    g.drawRect(10, 10, 100, 100);
}

From source file:FillRectPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.drawRect(10, 10, 80, 30);
    g.drawRoundRect(100, 10, 80, 30, 15, 15);
    g.drawOval(10, 100, 80, 30);//from   w ww .  j a v a 2  s.  c  om
    g.setColor(Color.red);
    g.fillRect(10, 10, 80, 30);
    g.fillRoundRect(100, 10, 80, 30, 15, 15);

    int thickness = 4;

    g.fill3DRect(200, 10, 80, 30, true);
    for (int i = 1; i <= thickness; i++)
        g.draw3DRect(200 - i, 10 - i, 80 + 2 * i - 1, 30 + 2 * i - 1, true);

    g.fill3DRect(200, 50, 80, 30, false);
    for (int i = 1; i <= thickness; i++)
        g.draw3DRect(200 - i, 50 - i, 80 + 2 * i - 1, 30 + 2 * i - 1, true);

    g.fillOval(10, 100, 80, 30);
}

From source file:DiamondIcon.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(color);//ww  w .j a  va 2  s. com
    g.drawRect(0, 0, 20, 20);
}

From source file:DrawRectPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(Color.blue);// w  ww .  j av a 2  s  . c  o  m
    g.drawRect(10, 10, 80, 30);
    g.drawRoundRect(100, 10, 80, 30, 15, 15);

    int thickness = 4;

    for (int i = 0; i <= thickness; i++)
        g.draw3DRect(200 - i, 10 - i, 80 + 2 * i, 30 + 2 * i, true);
    for (int i = 0; i < thickness; i++)
        g.draw3DRect(200 - i, 50 - i, 80 + 2 * i, 30 + 2 * i, false);

    g.drawOval(10, 100, 80, 30);
}

From source file:mainDraw.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.drawRect(x, y, 50, 50);
    g.fillRect(x, y, 50, 50);/* ww w .j  av  a 2s  . c  o m*/
    g.setColor(Color.BLACK);
}