List of usage examples for java.awt Graphics drawLine
public abstract void drawLine(int x1, int y1, int x2, int y2);
(x1, y1)
and (x2, y2)
in this graphics context's coordinate system. From source file:MainClass.java
public void paint(Graphics g) { d = getSize();/*from w w w . j a va2s. co m*/ g.drawLine(0, 0, d.width - 1, d.height - 1); g.drawLine(0, d.height - 1, d.width - 1, 0); g.drawRect(0, 0, d.width - 1, d.height - 1); }
From source file:Main.java
public void paint(Graphics g) { g.setColor(Color.red); g.drawRect(0, 0, 100, 100); g.clipRect(25, 25, 50, 50); g.drawLine(0, 100, 100, 0); }
From source file:Main.java
protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawLine(10, 100, 380, 100); g.drawLine(200, 30, 200, 190);// w w w . j a va 2 s. co m g.drawLine(380, 100, 370, 90); g.drawLine(380, 100, 370, 110); g.drawLine(200, 30, 190, 40); g.drawLine(200, 30, 210, 40); g.drawString("X", 360, 80); g.drawString("Y", 220, 40); Polygon p = new Polygon(); Polygon p2 = new Polygon(); for (int x = -170; x <= 170; x++) { p.addPoint(x + 200, 100 - (int) (50 * f((x / 100.0) * 2 * Math.PI))); } for (int x = -170; x <= 170; x++) { p2.addPoint(x + 200, 100 - (int) (50 * gCos((x / 100.0) * 2 * Math.PI))); } g.setColor(Color.red); g.drawPolyline(p.xpoints, p.ypoints, p.npoints); g.drawString("-2\u03c0", 95, 115); g.drawString("-\u03c0", 147, 115); g.drawString("\u03c0", 253, 115); g.drawString("2\u03c0", 305, 115); g.drawString("0", 200, 115); g.setColor(Color.blue); g.drawPolyline(p2.xpoints, p2.ypoints, p2.npoints); }
From source file:MyCanvas.java
public void paint(Graphics g) { int i = 10;//from ww w . j a v a 2s . c o m for (Color c : colors) { g.setColor(c); i += 10; g.drawLine(i, 10, 200, 200); } }
From source file:UnderlinedLabel.java
public void paint(Graphics g) { Rectangle r;//w w w. j a va2 s.com super.paint(g); r = g.getClipBounds(); g.drawLine(0, r.height - getFontMetrics(getFont()).getDescent(), getFontMetrics(getFont()).stringWidth(getText()), r.height - getFontMetrics(getFont()).getDescent()); }
From source file:MouseTest.java
public void paint(Graphics g) { super.paint(g); g.setColor(color); g.drawLine(startX, startY, endX, endY); }
From source file:Main.java
public void paint(Graphics g) { g.setColor(Color.red);/*from w w w.jav a2 s .co m*/ Graphics clippedGraphics = g.create(); clippedGraphics.drawRect(0, 0, 100, 100); clippedGraphics.clipRect(25, 25, 50, 50); clippedGraphics.drawLine(0, 0, 100, 100); clippedGraphics.dispose(); clippedGraphics = null; g.drawLine(0, 100, 100, 0); }
From source file:Main.java
public void paint(Graphics g) { g.setColor(Color.red);//from w w w .jav a 2 s .co m Graphics clippedGraphics = g.create(); clippedGraphics.drawRect(0, 0, 100, 100); clippedGraphics.clipRect(25, 25, 50, 50); clippedGraphics.drawLine(0, 0, 100, 100); clippedGraphics.finalize(); clippedGraphics = null; g.drawLine(0, 100, 100, 0); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; BasicStroke bs = new BasicStroke(16.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); g2.setStroke(bs);// w w w . j av a 2 s . c om g.drawLine(30, 20, 270, 20); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; BasicStroke bs = new BasicStroke(16.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); g2.setStroke(bs);/* ww w . j a va 2 s . co m*/ g.drawLine(30, 20, 270, 20); }