I am stuck... I am trying to fill random squares where the width of the box is odd with random colors using the fillRoundRect method where the archwidth and archeight should be a random number between 0 and one half of the smaller of the width and height. If the width of the square is even the color needs to be black. Here is what I have so far:
also the random colors I have selected to be red, green, blue and alpha


import javax.swing.JPanel;import java.awt.*;import java.util.Random; public class BoxesPanel extends JPanel{ private final int NUM_BOXES = 50, THICKNESS = 5, MAX_SIDE = 50; private final int MAX_X = 350, MAX_Y = 250; private Random generator; private int redComponent, grnComponent, bluComponent, alphaComponet; //----------------------------------------------------------------- // Sets up the drawing panel. //----------------------------------------------------------------- public BoxesPanel() { generator = new Random(); setBackground(Color.white); setPreferredSize(new Dimension(400, 300)); } //----------------------------------------------------------------- // Paints boxes of random width and height in a random location. // //----------------------------------------------------------------- public void paintComponent(Graphics page) { super.paintComponent(page); int x, y, width, height; for (int count = 0; count < NUM_BOXES; count++) { x = generator.nextInt(MAX_X) + 1; y = generator.nextInt(MAX_Y) + 1; width = generator.nextInt(MAX_SIDE) + 1; height = generator.nextInt(MAX_SIDE) + 1; if (width % 2 != 0) // check to see if the width of the box is odd { redComponent = generator.nextInt(256); grnComponent = generator.nextInt(256); bluComponent = generator.nextInt(256); alphaComponet = generator.nextInt(256); Color ranColor = new Color(redComponent, grnComponent, bluComponent, alphaComponet); page.fillRoundRect(x, y, width, height, arcWidth, arcHeight); } else { page.setColor(Color.black); page.fillRoundRect(x, y, width, height, arcWidth, arcHeight); } } }}

More...