Example usage for java.awt Graphics fillRect

List of usage examples for java.awt Graphics fillRect

Introduction

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

Prototype

public abstract void fillRect(int x, int y, int width, int height);

Source Link

Document

Fills the specified rectangle.

Usage

From source file:CenterTextRectangle.java

public void paint(Graphics g) {
    Dimension d = this.getSize();

    g.setColor(Color.white);//from  w w w. j a  v a 2  s  . c  o  m
    g.fillRect(0, 0, d.width, d.height);
    g.setColor(Color.black);
    g.setFont(f);
    drawCenteredString("This is centered.", d.width, d.height, g);
    g.drawRect(0, 0, d.width - 1, d.height - 1);
}

From source file:TabPanelwithImageIconCustom.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(Color.black);//from www  .ja  v  a  2  s.co  m
    g.fillRect(x + 4, y + 4, getIconWidth() - 8, getIconHeight() - 8);
    g.setColor(Color.cyan);
    g.fillRect(x + 6, y + 6, getIconWidth() - 12, getIconHeight() - 12);
}

From source file:SmoothMove.java

public void paintOffscreen(Graphics g) {
    int s = 100;
    g.setColor(Color.blue);
    g.fillRect(mX - s / 2, mY - s / 2, s, s);
}

From source file:Main.java

public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setPaint(texture);/*from   www  . j  a va  2 s . co  m*/
    g.fillRect(0, 0, getWidth(), getHeight());
    super.paintComponent(g);
}

From source file:Main.java

public void paintComponent(Graphics g) {
    g.setColor(Color.black);
    g.fillRect(0, 0, getWidth(), getHeight());
}

From source file:ButtonwithImageIcon.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(Color.black);//www . j  a v  a 2 s . com
    g.fillRect(x, y, getIconWidth(), getIconHeight());
    g.setColor(color);
    g.fillRect(x + borderWidth, y + borderWidth, getIconWidth() - 2 * borderWidth,
            getIconHeight() - 2 * borderWidth);
}

From source file:Main.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(color);
    g.fillRect(x, y, w, H);
}

From source file:Main.java

@Override
protected void paintComponent(Graphics g) {
    Rectangle clip = g.getClipBounds();
    g.setColor(new Color(new Random().nextInt()));
    g.fillRect(clip.x, clip.y, clip.width, clip.height);
}

From source file:Main.java

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(Color.blue);//from w w w.j  a  v  a  2s.  c o m
    g.fillRect(TILE, TILE, 3 * TILE, 3 * TILE);
}

From source file:SmoothMove.java

public void paint(Graphics g) {
    // Clear the offscreen image.
    Dimension d = getSize();/* w  w w .j  av  a 2  s.com*/
    checkOffscreenImage();
    Graphics offG = mImage.getGraphics();
    offG.setColor(getBackground());
    offG.fillRect(0, 0, d.width, d.height);
    // Draw into the offscreen image.
    paintOffscreen(mImage.getGraphics());
    // Put the offscreen image on the screen.
    g.drawImage(mImage, 0, 0, null);
}