List of usage examples for java.awt Graphics setColor
public abstract void setColor(Color c);
From source file:QandE.SquareIcon.java
public void paintIcon(Component c, Graphics g, int x, int y) { if (c.isEnabled()) { g.setColor(Color.RED); } else {//from w w w . j av a 2 s .co m g.setColor(Color.GRAY); } g.fillRect(x, y, SIZE, SIZE); }
From source file:DataBufferGrabber.java
protected void paintComponent(Graphics g) { // create an image BufferedImage bImg = new BufferedImage(SWATCH_SIZE, SWATCH_SIZE, BufferedImage.TYPE_INT_RGB); Graphics gImage = bImg.getGraphics(); gImage.setColor(Color.WHITE); gImage.fillRect(0, 0, SWATCH_SIZE, SWATCH_SIZE); // Time how long it takes to copy the managed version long managedTime = copyImage(g, bImg, 0, 0); System.out.println("Managed: " + managedTime + " ms"); // Now grab the pixel array, change the colors, re-run the test Raster raster = bImg.getRaster(); DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer(); int pixels[] = dataBuffer.getData(); for (int i = 0; i < pixels.length; ++i) { // Make all pixels black pixels[i] = 0;// w ww . j a v a 2 s .c o m } // Time this un-managed copy long unmanagedTime = copyImage(g, bImg, SWATCH_SIZE, 0); System.out.println("Unmanaged: " + unmanagedTime + " ms"); }
From source file:Main.java
public void paint(Graphics g) { int fontSize = 20; g.setFont(new Font("TimesRoman", Font.BOLD, fontSize)); String s = "www.java2s.com"; g.setColor(Color.black); g.drawString(s, 30, 30);//from ww w. j a v a 2 s. c o m }
From source file:Main.java
public void paint(Graphics g) { int fontSize = 20; g.setFont(new Font("TimesRoman", Font.PLAIN, fontSize)); String s = "www.java2s.com"; g.setColor(Color.black); g.drawString(s, 30, 30);/*from w ww.jav a 2 s.c om*/ }
From source file:painting.SwingPaintDemo4.java
public void paintSquare(Graphics g) { g.setColor(Color.RED); g.fillRect(xPos, yPos, width, height); g.setColor(Color.BLACK);/*from ww w.ja v a 2s . co m*/ g.drawRect(xPos, yPos, width, height); }
From source file:Main.java
public void paint(Graphics g) { int fontSize = 20; g.setFont(new Font("TimesRoman", Font.ITALIC, fontSize)); String s = "www.java2s.com"; g.setColor(Color.black); g.drawString(s, 30, 30);//from w w w.j ava 2 s. c om }
From source file:ColorIcon.java
public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(border); g.drawRect(x, y, iWidth - 1, iHeight - 2); x += insets.left;//from ww w. j a v a 2 s .com y += insets.top; int w = iWidth - insets.left - insets.right; int h = iHeight - insets.top - insets.bottom - 1; g.setColor(color); g.fillRect(x, y, w, h); }
From source file:SimpleBorder.java
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Insets insets = getBorderInsets(c); if (color != null) g.setColor(color); g.fill3DRect(0, 0, width - insets.right, insets.top, true); g.fill3DRect(0, insets.top, insets.left, height - insets.top, true); g.fill3DRect(insets.left, height - insets.bottom, width - insets.left, insets.bottom, true); g.fill3DRect(width - insets.right, 0, insets.right, height - insets.bottom, true); }
From source file:QandE.XMarksTheSpot.java
protected void paintComponent(Graphics g) { if (isOpaque()) { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(getForeground());//w w w. ja va 2 s .c o m } Graphics2D g2 = (Graphics2D) g; Insets insets = getInsets(); g2.setStroke(new BasicStroke(5.0f)); g2.draw(new Line2D.Double(insets.left, insets.top, getWidth() - insets.right, getHeight() - insets.bottom)); g2.draw(new Line2D.Double(insets.left, getHeight() - insets.bottom, getWidth() - insets.right, insets.top)); }
From source file:MainClass.java
public void paint(Graphics g) { Dimension d = this.getPreferredSize(); int fontSize = 20; g.setFont(new Font("TimesRoman", Font.PLAIN, fontSize)); g.setColor(Color.red); g.drawString("www.java2s.com", 10, 20); }