// purpose: use RGB import java.util.*; import javax.swing.*; import java.awt.*; public class BoxRedux { public static void main( String[] args ) { JFrame window = Window.make( "Coloring", 400, 200, Color.WHITE, true, true ); Graphics g = window.getContentPane().getGraphics(); for ( int i = 1; i < 100; ++i ) { Random die = new Random(); int v = die.nextInt(); int n = Math.abs( v ); int r1 = RGB.getRed( n ); int g1 = RGB.getGreen( n ); int b1 = RGB.getBlue( n ); Color c1 = new Color( r1, g1, b1 ); g.setColor( c1 ); g.fillRect( 50, 50, 75, 50 ); int b2 = n % 256; int g2 = ( n / 256 ) % 256; int r2 = ( n / ( 256 * 256 ) % 256 ); Color c2 = new Color( r2, g2, b2 ); g.setColor( c2 ); g.fillRect( 250, 50, 75, 50 ); Pause.moment(); } } }