12. ComboSplitScroll - Color class(defined in java.awt...

This preview shows page 1 - 4 out of 9 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 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);1
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.2
JLabel class(defined in javax.swing package)-An object of the JLabel class is a component that shows a string.It can be instantiated as:JLabel label1 = new JLabel(“Example”);where “Example” is the string shown in this case.To change the text string, we can use setText method as:label1.setText(“changing text”);

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture