List of usage examples for java.awt Graphics fillRect
public abstract void fillRect(int x, int y, int width, int height);
From source file:Main.java
@Override public void paintComponent(Graphics g) { int margin = 10; Dimension dim = getSize();/*from w w w. ja va2 s . c o m*/ super.paintComponent(g); g.setColor(Color.red); g.fillRect(margin, margin, dim.width - margin * 2, dim.height - margin * 2); }
From source file:components.Corner.java
protected void paintComponent(Graphics g) { // Fill me with dirty brown/orange. g.setColor(new Color(230, 163, 4)); g.fillRect(0, 0, getWidth(), getHeight()); }
From source file:Main.java
public void paintComponent(Graphics g) { ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(Color.black);//from ww w . j a v a 2 s .c o m g.drawString(month.format(date), 34, 36); g.setColor(Color.white); g.drawString(year.format(date), 235, 36); Calendar today = Calendar.getInstance(); today.setTime(date); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.DATE, 1); cal.add(Calendar.DATE, -cal.get(Calendar.DAY_OF_WEEK) + 1); for (int week = 0; week < 6; week++) { for (int d = 0; d < 7; d++) { Color col = Color.black; g.drawString(day.format(cal.getTime()), d * 30 + 46 + 4, week * 29 + 81 + 20); cal.add(Calendar.DATE, +1); } } }
From source file:DoubleBufferWithBufferedImage.java
public void paint(Graphics g) { Graphics screengc = null;//from w w w .ja va 2s.c o m screengc = g; g = buffer.getGraphics(); g.setColor(Color.blue); g.fillRect(0, 0, w, h); g.setColor(Color.red); for (int i = 0; i < w; i += gap) g.drawLine(i, 0, w - i, h); for (int i = 0; i < h; i += gap) g.drawLine(0, i, w, h - i); screengc.drawImage(buffer, 0, 0, null); }
From source file:Main.java
public void paint(Graphics g) { m_fm = g.getFontMetrics();/*from www . j a v a 2 s.co m*/ g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight()); g.setColor(getForeground()); g.setFont(getFont()); Insets insets = getInsets(); int x = insets.left; int y = insets.top + m_fm.getAscent(); StringTokenizer st = new StringTokenizer(getText(), "\t"); while (st.hasMoreTokens()) { String str = st.nextToken(); g.drawString(str, x, y); //insert distance for each tab x += m_fm.stringWidth(str) + 50; if (!st.hasMoreTokens()) break; } }
From source file:painting.SwingPaintDemo4.java
public void paintSquare(Graphics g) { g.setColor(Color.RED);//from w w w . jav a2 s. c o m g.fillRect(xPos, yPos, width, height); g.setColor(Color.BLACK); g.drawRect(xPos, yPos, width, height); }
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 w w . java2 s . com } // Time this un-managed copy long unmanagedTime = copyImage(g, bImg, SWATCH_SIZE, 0); System.out.println("Unmanaged: " + unmanagedTime + " ms"); }
From source file:intersection.java
public void paint(Graphics g) { g.drawRect(r.x, r.y, r.width, r.height); g.drawRect(r1.x, r1.y, r1.width, r1.height); Rectangle r2 = r.intersection(r1); System.out.println(r2);/*from ww w . ja v a 2s .c o m*/ g.fillRect(r2.x, r2.y, r2.width, r2.height); }
From source file:QandE.XMarksTheSpot.java
protected void paintComponent(Graphics g) { if (isOpaque()) { g.setColor(getBackground());/*from ww w . j av a2s. com*/ g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(getForeground()); } 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:Main.java
public void paint(Graphics g) { Dimension d = getSize();/*from www .j a v a 2s .com*/ int h = d.height; int w = d.width; g.setColor(color); if (rectangular) { g.fillRect(0, 0, w - 1, h - 1); } else { g.fillOval(0, 0, w - 1, h - 1); } }