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

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

From source file:Main.java

public void paint(Graphics g) {
    g.setColor(curColor);
    g.fillRect(0, 0, getWidth() - 1, getHeight() - 1);
}

From source file:MouseMotionEventDemo.java

public void paint(Graphics g) {
    g.setColor(Color.blue);
    g.fillRect(mX, mY, 5, 5);
}

From source file:Main.java

@Override
protected void paintComponent(Graphics g) {
    g.setColor(Color.GREEN);/*  w  w  w. j av  a  2 s  .  c  o  m*/
    g.fillRect(0, 0, getWidth(), getHeight());

    // uncomment the following to draw an image
    // Image img = ...;
    // g.drawImage(img, 0, 0, this);

    super.paintComponent(g);
}

From source file:Main.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(Color.red);/*w  ww.  j  a va  2 s  .  co m*/
    g.fillRect(0, 0, 33, 33);
    g.drawString("java2s.com", 0, 20);
}

From source file:Main.java

@Override
protected void paintComponent(Graphics g) {
    g.setColor(getBackground());/*  ww w . ja  v  a2s .com*/
    g.fillRect(0, 0, getWidth(), getHeight());
    try {
        Rectangle rect = modelToView(getCaretPosition());
        if (rect != null) {
            g.setColor(Color.RED);
            g.fillRect(0, rect.y, getWidth(), rect.height);
        }
    } catch (BadLocationException e) {
        System.out.println(e);
    }
    super.paintComponent(g);
}

From source file:LazySample.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(Color.RED);//from w ww. j  a  v  a  2  s. c o  m
    g.fillRect(1, 1, 20, 20);
}

From source file:union.java

public void paint(Graphics g) {
    g.setColor(Color.lightGray);//from  www  .  ja va 2s. c o 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:Main.java

Main() {
    getRootPane().setGlassPane(new JComponent() {
        public void paintComponent(Graphics g) {
            g.setColor(new Color(0, 0, 0, 100));
            g.fillRect(0, 0, getWidth(), getHeight());
            super.paintComponent(g);
        }//  w w  w  .j  av  a 2  s .  c  om
    });
    JButton popDialog = new JButton("Block Frame");
    popDialog.addActionListener(e -> {
        getRootPane().getGlassPane().setVisible(true);
        JOptionPane.showMessageDialog(Main.this, "Shady!");
        getRootPane().getGlassPane().setVisible(false);
    });
    setContentPane(popDialog);
    pack();
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setSize(350, 180);
}

From source file:XORPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(Color.red);/*from w  w w  .  jav  a  2s .c o m*/
    g.fillRect(10, 10, 80, 30);
    g.setColor(Color.green);
    g.fillRect(50, 20, 80, 30);
    g.setColor(Color.blue);
    g.fillRect(130, 40, 80, 30);
    g.setXORMode(Color.green);
    g.fillRect(90, 30, 80, 30);
}