Example usage for java.awt Graphics drawRoundRect

List of usage examples for java.awt Graphics drawRoundRect

Introduction

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

Prototype

public abstract void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight);

Source Link

Document

Draws an outlined round-cornered rectangle using this graphics context's current color.

Usage

From source file:MainClass.java

public void paint(Graphics g) {
    g.drawRoundRect(25, 50, 100, 100, 25, 50);
}

From source file:MainClass.java

public void paint(Graphics g) {
    g.drawRect(10, 10, 60, 50);/*from  w  w w.  j  ava2 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:FillRectPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.drawRect(10, 10, 80, 30);//from  w ww . j  a  va  2  s  . c om
    g.drawRoundRect(100, 10, 80, 30, 15, 15);
    g.drawOval(10, 100, 80, 30);
    g.setColor(Color.red);
    g.fillRect(10, 10, 80, 30);
    g.fillRoundRect(100, 10, 80, 30, 15, 15);

    int thickness = 4;

    g.fill3DRect(200, 10, 80, 30, true);
    for (int i = 1; i <= thickness; i++)
        g.draw3DRect(200 - i, 10 - i, 80 + 2 * i - 1, 30 + 2 * i - 1, true);

    g.fill3DRect(200, 50, 80, 30, false);
    for (int i = 1; i <= thickness; i++)
        g.draw3DRect(200 - i, 50 - i, 80 + 2 * i - 1, 30 + 2 * i - 1, true);

    g.fillOval(10, 100, 80, 30);
}

From source file:DrawRectPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(Color.blue);/*from w  w  w . j  av a2  s .  c  o  m*/
    g.drawRect(10, 10, 80, 30);
    g.drawRoundRect(100, 10, 80, 30, 15, 15);

    int thickness = 4;

    for (int i = 0; i <= thickness; i++)
        g.draw3DRect(200 - i, 10 - i, 80 + 2 * i, 30 + 2 * i, true);
    for (int i = 0; i < thickness; i++)
        g.draw3DRect(200 - i, 50 - i, 80 + 2 * i, 30 + 2 * i, false);

    g.drawOval(10, 100, 80, 30);
}

From source file:Splash.java

public void paint(Graphics g) {
    im.paintIcon(this, g, 0, 0);
    g.setColor(Color.green);//  w ww . j a v  a2  s.c  om
    g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 7, 7);
}

From source file:edu.clemson.cs.nestbed.client.gui.MotePanel.java

public void paintDisabledPattern(Graphics g) {
    int arcSize = 4;
    int width = getWidth() - 1;
    int height = getHeight() - 1;

    g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arcSize, arcSize);

    for (int i = 1, numLines = 3; i <= numLines; ++i) {
        g.drawLine(width / numLines * i, 0, 0, height / numLines * i);
        g.drawLine(width, height / numLines * i, width / numLines * i, height);
    }//from w ww . j a va2s .  c om
}

From source file:MainClass.java

public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
    g.setColor(getWallColor());//w w  w  . j a  va2 s. co  m

    //  Paint a tall wall around the component
    for (int i = 0; i < sinkLevel; i++) {
        g.drawRoundRect(x + i, y + i, w - i - 1, h - i - 1, sinkLevel - i, sinkLevel);
        g.drawRoundRect(x + i, y + i, w - i - 1, h - i - 1, sinkLevel, sinkLevel - i);
        g.drawRoundRect(x + i, y, w - i - 1, h - 1, sinkLevel - i, sinkLevel);
        g.drawRoundRect(x, y + i, w - 1, h - i - 1, sinkLevel, sinkLevel - i);
    }
}

From source file:ColorVariousObjects.java

public void paint(Graphics g) {
    Color c1 = new Color(255, 100, 100);
    Color c2 = new Color(100, 255, 100);
    Color c3 = new Color(100, 100, 255);

    g.setColor(c1);//ww  w .  j ava 2 s  . c om
    g.drawLine(0, 0, 100, 100);
    g.drawLine(0, 100, 100, 0);

    g.setColor(c2);
    g.drawLine(40, 25, 250, 180);
    g.drawLine(75, 90, 400, 400);

    g.setColor(c3);
    g.drawLine(20, 150, 400, 40);
    g.drawLine(5, 290, 80, 19);

    g.setColor(Color.red);
    g.drawOval(10, 10, 50, 50);
    g.fillOval(70, 90, 140, 100);

    g.setColor(Color.blue);
    g.drawOval(190, 10, 90, 30);
    g.drawRect(10, 10, 60, 50);

    g.setColor(Color.cyan);
    g.fillRect(100, 10, 60, 50);
    g.drawRoundRect(190, 10, 60, 50, 15, 15);
}

From source file:edu.clemson.cs.nestbed.client.gui.MoteManagementPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);

    if (moteDepConfig == null) {
        paintDisabledPattern(g);/*www. j a  v  a 2s .  c  o m*/
    } else if (drawBorder) {
        Color oldColor = g.getColor();
        Color newColor = (installedSuccessfully || (installAnimationThread != null)) ? Color.green : Color.red;
        int arcSize = 4;

        g.setColor(newColor);
        g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arcSize, arcSize);
        g.setColor(oldColor);
    }
}

From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java

/**
 * convenience method for internal use. paints a log item handle
 * visualization.//  w  w w  .ja  v  a 2 s. com
 * 
 * @param x
 *            horizontal anchor coordinate of the handle
 * @param y
 *            vertical anchor coordinate of the handle
 * @param g
 *            the Graphics object used for painting
 */
protected void paintItem(int x, int y, Graphics g, String shape) {
    if (shape.equals(STR_NONE)) {
        return;
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DOT)) {
        g.fillOval(x - 2, y - 2, 4, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_BOX)) {
        g.fill3DRect(x - 5, y - 5, 10, 10, false);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_CIRCLE)) {
        g.fillOval(x - 5, y - 5, 11, 11);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_RHOMBUS)) {
        int rhombX[] = { x, x - 5, x, x + 5 };
        int rhombY[] = { y - 5, y, y + 5, y };
        g.fillPolygon(rhombX, rhombY, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_TRIANGLE)) {
        int triX[] = { x, x - 5, x + 5 };
        int triY[] = { y + 5, y - 5, y - 5 };
        g.fillPolygon(triX, triY, 3);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_ROUND_BOX)) {
        g.fillRoundRect(x - 5, y - 5, 10, 10, 2, 2);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_BOX)) {
        g.drawRect(x - 5, y - 5, 10, 10);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_CIRCLE)) {
        g.drawOval(x - 5, y - 5, 11, 11);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_RHOMBUS)) {
        int rhombX[] = { x, x - 5, x, x + 5 };
        int rhombY[] = { y - 5, y, y + 5, y };
        g.drawPolygon(rhombX, rhombY, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_TRIANGLE)) {
        int triX[] = { x, x - 5, x + 5 };
        int triY[] = { y + 5, y - 5, y - 5 };
        g.drawPolygon(triX, triY, 3);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_ROUND_BOX)) {
        g.drawRoundRect(x - 5, y - 5, 10, 10, 2, 2);
    }
}