// // another simple example of the Java AWT, showing use of // foreground, background colors. // the main method defines many Labels with different foreground and // background colors. // import java.awt.* ; import java.awt.event.* ; class ColorLabels { // no command-line arguments. public static void main(String[] args) { Color[] colors = new Color[] { Color.black, Color.blue, Color.cyan, Color.green, Color.magenta, Color.orange, Color.pink, Color.red, Color.white, Color.yellow } ; CloseableFrame f = new CloseableFrame() ; f.setLayout(new GridLayout(colors.length, 2, 10, 10)) ; for (int i = 0 ; i < colors.length ; i++) { Label l1 = new Label("hello!", Label.CENTER) ; Label l2 = new Label("hello!", Label.CENTER) ; l1.setForeground(colors[i]) ; l2.setBackground(colors[i]) ; f.add(l1) ; f.add(l2) ; } f.pack() ; f.show() ; } }