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
public void paint(Graphics g) { Rectangle r = new Rectangle(50, 50, 100, 100); Rectangle r1 = new Rectangle(100, 100, 75, 75); 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 w ww . jav a 2 s.c o m*/ g.fillRect(r2.x, r2.y, r2.width, r2.height); }
From source file:ScrollPaneWatermark.java
public void paintComponent(Graphics g) { // do the superclass behavior first super.paintComponent(g); // paint the texture if (texture != null) { Graphics2D g2 = (Graphics2D) g; g2.setPaint(texture);/* w w w . j a v a2 s . c o m*/ g.fillRect(0, 0, getWidth(), getHeight()); } }
From source file:Sketch.java
public void actionPerformed(ActionEvent e) { // The button must have been pressed. Insets insets = board.getInsets(); Graphics g = board.getGraphics(); g.setColor(board.getBackground());// w ww.java 2s.c om g.fillRect(insets.left, insets.top, board.getWidth() - insets.left - insets.right, board.getHeight() - insets.top - insets.bottom); }
From source file:com.krawler.esp.handlers.genericFileUpload.java
private BufferedImage toBufferedImage(Image image) { image = new ImageIcon(image).getImage(); BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); Graphics g = bufferedImage.createGraphics(); g.setColor(Color.white);//ww w.java 2 s .c o m g.fillRect(0, 0, image.getWidth(null), image.getHeight(null)); g.drawImage(image, 0, 0, null); g.dispose(); return bufferedImage; }
From source file:yp.tibco.com.yang.lottery.server.LotteryServerIoHandler.java
/** * Create an image using the specified request and the text. * * @param request//from w w w .j a v a 2 s .c o m * Determines the height and width of the image * @param text * The text that is placed in the image * @return * a BufferedImage representing the text. */ private BufferedImage createImage(ImageRequest request, String text) { BufferedImage image = new BufferedImage(request.getWidth(), request.getHeight(), BufferedImage.TYPE_BYTE_INDEXED); Graphics graphics = image.createGraphics(); graphics.setColor(Color.YELLOW); graphics.fillRect(0, 0, image.getWidth(), image.getHeight()); Font serif = new Font("serif", Font.PLAIN, 30); graphics.setFont(serif); graphics.setColor(Color.BLUE); graphics.drawString(text, 10, 50); return image; }
From source file:com.krawler.esp.handlers.FileUploadHandler.java
private BufferedImage toBufferedImage(Image image, int type) { image = new ImageIcon(image).getImage(); BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); Graphics g = bufferedImage.createGraphics(); if (type == BufferedImage.TYPE_INT_RGB) { g.setColor(Color.white);/*from w ww . j a va 2 s. c o m*/ g.fillRect(0, 0, image.getWidth(null), image.getHeight(null)); } g.drawImage(image, 0, 0, null); g.dispose(); return bufferedImage; }
From source file:uk.co.modularaudio.util.swing.colouredtoggle.ColouredTextToggle.java
@Override public void paint(final Graphics g) { super.paint(g); g.setColor(backgroundColour);//from w ww .j a va 2 s.c om final int yOffset = Math.round((getHeight() / 2.0f) - (CLICKABLE_BOX_WIDTH / 2.0f)); g.fillRect(4, 4 + yOffset, CLICKABLE_BOX_WIDTH - 8, CLICKABLE_BOX_WIDTH - 8); if (active) { // Draw an X inside the box g.setColor(surroundColour); g.drawLine(5, 5 + yOffset, CLICKABLE_BOX_WIDTH - 6, CLICKABLE_BOX_WIDTH - 6 + yOffset); g.drawLine(CLICKABLE_BOX_WIDTH - 6, 5 + yOffset, 5, CLICKABLE_BOX_WIDTH - 6 + yOffset); } }
From source file:jurls.core.utils.MatrixImage.java
@Override public void paint(Graphics g) { if (image == null) { g.setColor(Color.GRAY);/* w w w. j a v a 2 s. c o m*/ g.fillRect(0, 0, getWidth(), getHeight()); } else g.drawImage(image, 0, 0, getWidth(), getHeight(), null); }
From source file:ColorDifference.java
/** * Displays our component with the animating colors of the areas on the left * and right, separated by an area of white in the middle *//*from w ww . jav a 2 s .co m*/ @Override protected void paintComponent(Graphics g) { int fadeX = 0; int blankX = getWidth() / 3; int bigRectW = getWidth() / 3; // Fill left-side rectangle with current animating color g.setColor(largeRectColors[colorIndex]); g.fillRect(0, 0, bigRectW, getHeight()); // Fill middle area with white g.setColor(Color.WHITE); g.fillRect(bigRectW, 0, bigRectW, getHeight()); // Fill right-side rectangle with black, with a white square // in the middle int bigRectX = 2 * bigRectW; int smallRectW = 4; int smallRectH = 4; int smallRectX = bigRectX + (bigRectW / 2) - (smallRectW / 2); int smallRectY = (getHeight() / 2) - (smallRectH / 2); g.setColor(Color.BLACK); g.fillRect(2 * getWidth() / 3, 0, getWidth() / 3, getHeight()); g.setColor(smallRectColors[colorIndex]); g.fillRect(smallRectX, smallRectY, smallRectW, smallRectH); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.lightGray);/* ww w.j a v a 2 s. co m*/ int w = getWidth() / TILE + 1; int h = getHeight() / TILE + 1; for (int row = 0; row < h; row++) { for (int col = 0; col < w; col++) { if ((row + col) % 2 == 0) { g.fillRect(col * TILE, row * TILE, TILE, TILE); } } } }