ColorsDisplayed

ColorsDisplayed - SwingConstants.CENTER); bottomrightJL =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//ColorsDisplayed Applet / import java.awt.*; import javax.swing.*; i public class ColorsDisplayed extends JApplet { JLabel topleftJL, toprightJL, bottomleftJL, bottomrightJL; int i; float red, green, blue; public void init() { Container c = getContentPane(); c.setLayout(new GridLayout(2, 2)); c.setBackground(Color.white); topleftJL = new JLabel("Red", SwingConstants.CENTER); toprightJL = new JLabel("Green", SwingConstants.CENTER); bottomleftJL = new JLabel("Blue",
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: SwingConstants.CENTER); bottomrightJL = new JLabel("Random", SwingConstants.CENTER); topleftJL.setForeground(Color.red); toprightJL.setForeground(Color.green); bottomleftJL.setForeground(Color.blue); red = (float) Math.random(); green = (float) Math.random(); blue = (float) Math.random(); bottomrightJL.setForeground(new Color(red, green, blue)); c.add(topleftJL); c.add(toprightJL); c.add(bottomleftJL); c.add(bottomrightJL); } }...
View Full Document

Ask a homework question - tutors are online