hw6Fall10 - 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

hw6Fall10 - Color class(defined in java.awt package-An...

This preview shows page 1 - 4 out of 8 pages.

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 red defined in the Color class. Each of RGB value varies between 0 and 255. ( 8bits) Object Color.black Color.blue Color.cyan Color.orange Color.white Color.yellow RGB Value 0, 0, 0 0, 0, 255 0, 255, 255 255, 200, 0 255, 255, 255 255, 255, 0 There 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.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture