Example usage for java.awt Graphics fillOval

List of usage examples for java.awt Graphics fillOval

Introduction

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

Prototype

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

Source Link

Document

Fills an oval bounded by the specified rectangle with the current color.

Usage

From source file:OvalIcon.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    if (color != null) {
        int width = getIconWidth();
        int height = getIconHeight();
        g.setColor(color);// w w  w .  j av  a 2  s .c  o  m
        g.fillOval(x, y, width, height);
    }
}

From source file:BezLab.java

public void paint(Graphics g) {
    for (int i = 0; i < 4; i++) {
        if (i == 0 || i == 3)
            g.setColor(Color.blue);
        else// www  . jav  a  2  s .co m
            g.setColor(Color.cyan);
        g.fillOval(xs[i] - 6, ys[i] - 6, 12, 12);
    }
    Graphics2D g2d = (Graphics2D) g;
    g2d.setColor(Color.black);
    GeneralPath path = new GeneralPath();
    path.moveTo(xs[0], ys[0]);
    path.curveTo(xs[1], ys[1], xs[2], ys[2], xs[3], ys[3]);
    g2d.draw(path);
}

From source file:GlassPaneDemo.java

protected void paintComponent(Graphics g) {
    if (point != null) {
        g.setColor(Color.red);/*from  w w  w  .  j  a va2  s  .  com*/
        g.fillOval(point.x - 10, point.y - 10, 20, 20);
    }
}

From source file:CopyAreaPerformance.java

private void drawSmiley(Graphics g, Color faceColor, int x, int y) {
    // fill face color
    g.setColor(faceColor);/* w  w  w  .j  a  va 2 s  . co  m*/
    g.fillOval(x, y, SMILEY_SIZE, SMILEY_SIZE);
    g.setColor(Color.BLACK);
    // draw head
    g.drawOval(x, y, SMILEY_SIZE, SMILEY_SIZE);
    // draw smile
    g.drawArc(x + (int) ((SMILEY_SIZE * .2)), (int) (y + (SMILEY_SIZE * .2)), (int) (SMILEY_SIZE * .6),
            (int) (SMILEY_SIZE * .6), 200, 140);
    // draw eyes
    int eyeSize = Math.max(2, (int) (SMILEY_SIZE * .1));
    g.fillOval(x + (int) ((SMILEY_SIZE * .5) - (SMILEY_SIZE * .1) - eyeSize), y + (int) (SMILEY_SIZE * .3),
            eyeSize, eyeSize);
    g.fillOval(x + (int) ((SMILEY_SIZE * .5) + (SMILEY_SIZE * .1)), y + (int) (SMILEY_SIZE * .3), eyeSize,
            eyeSize);
}

From source file:ImageTransferTest.java

public ImageTransferFrame() {
    setTitle("ImageTransferTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    label = new JLabel();
    image = new BufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.TYPE_INT_ARGB);
    Graphics g = image.getGraphics();
    g.setColor(Color.WHITE);//from ww w.ja  v a2 s  . c  om
    g.fillRect(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
    g.setColor(Color.RED);
    g.fillOval(DEFAULT_WIDTH / 4, DEFAULT_WIDTH / 4, DEFAULT_WIDTH / 2, DEFAULT_HEIGHT / 2);

    label.setIcon(new ImageIcon(image));
    add(new JScrollPane(label), BorderLayout.CENTER);
    JPanel panel = new JPanel();

    JButton copyButton = new JButton("Copy");
    panel.add(copyButton);
    copyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            copy();
        }
    });

    JButton pasteButton = new JButton("Paste");
    panel.add(pasteButton);
    pasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            paste();
        }
    });

    add(panel, BorderLayout.SOUTH);
}

From source file:MainClass.java

public void paint(Graphics g) {

    Graphics2D g2 = (Graphics2D) g;

    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);//from ww w .  ja v a2s. c o  m

    int x = 40, y = 40;

    g.setColor(Color.red);
    g.fillOval(x, y, 50, 50);

    Composite old = g2.getComposite();

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN));

    g.setColor(Color.green);
    g.fillOval(x + 30, y + 30, 30, 30);

    g2.setComposite(old);

    g.setColor(Color.black);
    g.drawString("AlphaComposite.SRC_IN", x, y + 80);

}

From source file:MainClass.java

public void paint(Graphics g) {

    Graphics2D g2 = (Graphics2D) g;

    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);/*from  w ww  .j  av  a 2s .c  om*/

    int x = 40, y = 40;

    g.setColor(Color.red);
    g.fillOval(x, y, 50, 50);

    Composite old = g2.getComposite();

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OUT));

    g.setColor(Color.green);
    g.fillOval(x + 30, y + 30, 30, 30);

    g2.setComposite(old);

    g.setColor(Color.black);
    g.drawString("AlphaComposite.SRC_OUT", x, y + 80);

}

From source file:MainClass.java

public void paint(Graphics g) {

    Graphics2D g2 = (Graphics2D) g;

    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);/*from   w ww. j  a va 2  s  .com*/

    int x = 40, y = 40;

    g.setColor(Color.red);
    g.fillOval(x, y, 50, 50);

    Composite old = g2.getComposite();

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));

    g.setColor(Color.green);
    g.fillOval(x + 30, y + 30, 30, 30);

    g2.setComposite(old);

    g.setColor(Color.black);
    g.drawString("AlphaComposite.SRC_OVER", x, y + 80);

}

From source file:MainClass.java

public void paint(Graphics g) {

    Graphics2D g2 = (Graphics2D) g;

    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);//from w  w w  .j a v a  2  s.  com

    int x = 40, y = 40;

    g.setColor(Color.red);
    g.fillOval(x, y, 50, 50);

    Composite old = g2.getComposite();

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OUT));

    g.setColor(Color.green);
    g.fillOval(x + 30, y + 30, 30, 30);

    g2.setComposite(old);

    g.setColor(Color.black);
    g.drawString("AlphaComposite.DST_OUT", x, y + 80);

}

From source file:MainClass.java

public void paint(Graphics g) {

    Graphics2D g2 = (Graphics2D) g;

    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);/*w  w w.  j  a  va 2 s .com*/

    int x = 40, y = 40;

    g.setColor(Color.red);
    g.fillOval(x, y, 50, 50);

    Composite old = g2.getComposite();

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC));

    g.setColor(Color.green);
    g.fillOval(x + 30, y + 30, 30, 30);

    g2.setComposite(old);

    g.setColor(Color.black);
    g.drawString("AlphaComposite.SRC", x, y + 80);

}