Example usage for java.awt Graphics setColor

List of usage examples for java.awt Graphics setColor

Introduction

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

Prototype

public abstract void setColor(Color c);

Source Link

Document

Sets this graphics context's current color to the specified color.

Usage

From source file:Main.java

public void paint(Graphics g) {
    g.fillRect(0, 0, 20, 20);//  w ww.  j  a  va 2  s .c  o  m

    Graphics2D g2 = (Graphics2D) g;

    g2.translate(50, 50);
    g2.rotate(30.0 * Math.PI / 180.0);

    g2.scale(2.0, 2.0);

    g.setColor(Color.red);

    g.fillRect(0, 0, 20, 20);
}

From source file:no.java.swing.SelectableLabel.java

@Override
protected void paintComponent(Graphics g) {
    if (isOpaque()) {
        g.setColor(getBackground());
        g.fillRect(0, 0, getWidth(), getHeight());
    }/*from  ww  w . ja  v a 2s. c o  m*/
}

From source file:org.openlegacy.rpc.render.DefaultRpcImageRenderer.java

private void setDefaultColor(Graphics graphics) {
    graphics.setColor(imageDefaultTextColor);
}

From source file:Main.java

@Override
protected void paintIndeterminate(Graphics g, JComponent c) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    r = getBox(r);//from   w w  w.  ja  v  a2  s  . co m
    g.setColor(progressBar.getForeground());
    g.fillOval(r.x, r.y, r.width, r.height);
}

From source file:Main.java

public void paint(Graphics g) {
    g.fillRect(0, 0, 20, 20);/*  ww w . ja  va 2 s.c o m*/

    Graphics2D g2 = (Graphics2D) g;

    g2.translate(5.3, 5.4);
    g2.rotate(30.0 * Math.PI / 180.0);

    g2.scale(2.0, 2.0);

    g.setColor(Color.red);

    g.fillRect(0, 0, 20, 20);
}

From source file:ColorSource.java

public void dragGestureRecognized(DragGestureEvent e) {
    // Create an image we can drag along with us.
    // Not all systems support this, but it doesn't hurt to try.
    Image colorblock = this.createImage(25, 25);
    Graphics g = colorblock.getGraphics();
    g.setColor(color);
    g.fillRect(0, 0, 25, 25);/*from   w w  w .j  av a2  s  .  c om*/

    // Start dragging our transferable color object.
    e.startDrag(DragSource.DefaultMoveDrop, // The initial drag cursor
            colorblock, new Point(0, 0), // The image to drag
            tcolor, // The data being dragged
            this); // Who to notify during drag
}

From source file:BottomBorder.java

public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    Color oldColor = g.getColor();
    int i;//from   w  ww .j  av a  2  s .c om

    g.setColor(lineColor);
    for (i = 0; i < thickness; i++) {
        g.drawLine(x, y + height - i - 1, x + width, y + height - i - 1);
    }
    g.setColor(oldColor);
}

From source file:Main.java

public void paint(Graphics g) {
    int fontSize = 20;
    Font font = new Font("TimesRoman", Font.PLAIN, fontSize);
    g.setFont(font);//from  w  ww . j  av a 2 s.c  om

    font.canDisplay('A');

    String s = "www.java2s.com";

    g.setColor(Color.black);
    g.drawString(s, 30, 30);
}

From source file:MainClass.java

public void paint(Graphics g) {

    g.fillRect(0, 0, 20, 20);//  w w w  .  j  a v a2s . com

    Graphics2D g2 = (Graphics2D) g;

    g2.translate(50, 50);
    g2.rotate(30.0 * Math.PI / 180.0);

    g2.scale(2.0, 2.0);

    g.setColor(Color.red);

    g.fillRect(0, 0, 20, 20);

}

From source file:Main.java

public void paint(Graphics g) {
    g.fillRect(0, 0, 20, 20);/*from   ww w  .  j a  va 2 s .  co  m*/

    Graphics2D g2 = (Graphics2D) g;

    g2.translate(50, 50);
    g2.rotate(30.0 * Math.PI / 180.0, 13, 12);

    g2.scale(2.0, 2.0);

    g.setColor(Color.red);

    g.fillRect(0, 0, 20, 20);
}