List of usage examples for java.awt Graphics drawRect
public void drawRect(int x, int y, int width, int height)
From source file:painting.SwingPaintDemo4.java
public void paintSquare(Graphics g) { g.setColor(Color.RED);//from w ww . j a v a 2s . c om g.fillRect(xPos, yPos, width, height); g.setColor(Color.BLACK); g.drawRect(xPos, yPos, width, height); }
From source file:CenterTextRectangle.java
public void paint(Graphics g) { Dimension d = this.getSize(); g.setColor(Color.white);/*w w w . j ava 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:CheckBoxIcon.java
public void paintIcon(Component component, Graphics g, int x, int y) { AbstractButton abstractButton = (AbstractButton) component; ButtonModel buttonModel = abstractButton.getModel(); Color color = buttonModel.isSelected() ? Color.BLUE : Color.RED; g.setColor(color);//from w w w.j a v a2 s. c o m g.drawRect(1, 1, 20, 20); }
From source file:PrintSampleApp.java
public void paint(Graphics g) { Dimension size = getSize();/*from ww w. ja v a 2 s .co m*/ int width = size.width; int height = size.height; int x1 = (int) (width * 0.1); int x2 = (int) (width * 0.9); int y1 = (int) (height * 0.1); int y2 = (int) (height * 0.9); g.drawRect(x1, y1, x2 - x1, y2 - y1); g.drawOval(x1, y1, x2 - x1, y2 - y1); g.drawLine(x1, y1, x2, y2); g.drawLine(x2, y1, x1, y2); String text = "Print Me! "; text += text; text += text; g.drawString(text, x1, (int) ((y1 + y2) / 2)); g.dispose(); }
From source file:painting.SwingPaintDemo3.java
protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawString("This is my custom Panel!", 10, 20); g.setColor(Color.RED);//www . ja va2 s. com g.fillRect(squareX, squareY, squareW, squareH); g.setColor(Color.BLACK); g.drawRect(squareX, squareY, squareW, squareH); }
From source file:StringRectPaintPanel.java
public void paint(Graphics g) { g.setFont(new Font("", 0, 100)); FontMetrics fm = getFontMetrics(new Font("", 0, 100)); String s = "java2s"; int x = 5;/*from w w w . j a v a 2 s . c o m*/ int y = 5; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); int h = fm.getHeight(); int w = fm.charWidth(c); g.drawRect(x, y, w, h); g.drawString(String.valueOf(c), x, y + h); x = x + w; } }
From source file:org.kalypso.ogc.gml.map.widgets.builders.RectangleGeometryBuilder.java
private void drawHandles(final Graphics g, final int[] x, final int[] y) { final int sizeOuter = 6; if (y.length > 2) { g.drawRect(x[0] - sizeOuter / 2, y[0] - sizeOuter / 2, sizeOuter, sizeOuter); g.drawRect(x[2] - sizeOuter / 2, y[2] - sizeOuter / 2, sizeOuter, sizeOuter); }//from w w w .j av a2 s . c o m }
From source file:com.cburch.logisim.circuit.appear.AppearancePort.java
@Override public void paint(Graphics g, HandleGesture gesture) { Location location = getLocation(); int x = location.getX(); int y = location.getY(); g.setColor(COLOR);/*from www. j a v a 2 s . c om*/ if (isInput()) { int r = INPUT_RADIUS; g.drawRect(x - r, y - r, 2 * r, 2 * r); } else { int r = OUTPUT_RADIUS; g.drawOval(x - r, y - r, 2 * r, 2 * r); } g.fillOval(x - MINOR_RADIUS, y - MINOR_RADIUS, 2 * MINOR_RADIUS, 2 * MINOR_RADIUS); }
From source file:DiamondAbstractButtonStateIcon.java
public void paintIcon(Component component, Graphics g, int x, int y) { if (component instanceof AbstractButton) { AbstractButton abstractButton = (AbstractButton) component; boolean selected = abstractButton.isSelected(); if (selected) { g.setColor(Color.RED); } else {// w ww . j a v a 2 s . c o m g.setColor(Color.BLUE); } g.drawRect(0, 0, 20, 20); } }
From source file:test.mandelbrot.MandelbrotApp.java
@Override public void paint(Graphics g) { if (done) {//w w w .ja va2 s . com g.drawImage(offscreen, 0, 0, this); this.setTitle("Done"); } else { g.drawImage(offscreen, 0, 0, this); g.setColor(Color.white); g.drawRect(WIDTH / 4, 10, WIDTH / 2, 5); g.fillRect(WIDTH / 4, 11, (progress * (WIDTH / 2)) / HEIGHT, 4); } }