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:ComplexCellRenderer.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(Color.RED);//w w w. j a va  2  s.  c  o m
    g.drawRect(0, 0, 25, 25);
}

From source file:Main.java

public void paint(Graphics g) {
    Rectangle r = new Rectangle(50, 50, 100, 100);
    Rectangle r1 = new Rectangle(100, 100, 75, 75);
    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);// w  ww .j ava  2  s .  co m
    g.fillRect(r2.x, r2.y, r2.width, r2.height);
}

From source file:MainClass.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(myColor);//from  w w w  . jav a2s  .c  o m
    g.drawRect(0, 0, 16, 16);
}

From source file:org.stanwood.nwn2.gui.view.UIIconView.java

private void drawMissingIcon(int x, int y, int width, int height, Graphics g) {
    g.setColor(Color.RED);// w w w . ja  va  2  s.com

    g.drawRect(x, y, width, height);

    g.drawLine(x, y, x + width, y + height);
    g.drawLine(x + width, y, x, y + height);
}

From source file:Simple.java

public void paint(Graphics g) {
    //Draw a Rectangle around the applet's display area.
    g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);

    //Draw the current string inside the rectangle.
    g.drawString(buffer.toString(), 5, 15);
}

From source file:union.java

public void paint(Graphics g) {
    g.setColor(Color.lightGray);// w  w w  . ja v  a2  s .  co  m
    Rectangle r2 = r.union(r1);
    g.fillRect(r2.x, r2.y, r2.width, r2.height);
    g.setColor(Color.black);
    g.drawRect(r.x, r.y, r.width, r.height);
    g.drawRect(r1.x, r1.y, r1.width, r1.height);
}

From source file:ColorIcon.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(border);/*  ww w.  j av a2  s. c om*/
    g.drawRect(x, y, iWidth - 1, iHeight - 2);

    x += insets.left;
    y += insets.top;

    int w = iWidth - insets.left - insets.right;
    int h = iHeight - insets.top - insets.bottom - 1;

    g.setColor(color);
    g.fillRect(x, y, w, h);
}

From source file:MainClass.java

public void paint(Graphics g) {
    d = getSize();//from   w  w w.  j a va2  s . co  m

    g.drawLine(0, 0, d.width - 1, d.height - 1);
    g.drawLine(0, d.height - 1, d.width - 1, 0);
    g.drawRect(0, 0, d.width - 1, d.height - 1);
}

From source file:URLButton.java

/** paint() method just draws a box around us */
public void paint(Graphics g) {
    // super.paint(graphics g);
    Dimension d = getSize();//w w w.j a v a  2 s.c o  m
    g.drawRect(0, 0, d.width - 1, d.height - 1);
}

From source file:width.java

public void paint(Graphics g) {
    g.drawRect(0, 0, 
               getSize().width - 1, getSize().height - 1);
}