Color class(defined in java.awt package)-An object of the Color class represents a color.-It can be defined by RGB (red, green, and blue) value. There are also pre-defined colors such as reddefined in the Color class.Each of RGB value varies between 0 and 255. ( 8bits)ObjectColor.blackColor.blueColor.cyanColor.orangeColor.whiteColor.yellowRGB Value0, 0, 00, 0, 2550, 255, 255255, 200, 0255, 255, 255255, 255, 0There are foreground color and background color.Foreground color – color used to draw shapes or strings.If comp is a component object, we can set foreground color as follows:comp.setForeground(Color.red);To set background color:comp.setBackground(Color.blue);
JButton class(defined in javax.swing package)-An object of the JButton class is a button that a user can push.It can be instantiated as:JButton button1 = new JButton(“Button 1”);where “Button 1” is the string shown in the button in this case.
JLabel class(defined in javax.swing package)-An object of the JLabel class is a component that shows a string.