Java
Swing - GUIs LESSON NOTE In
this lesson, we will look at components more closely. The components in Swing are called JComponents (though we often simply say Components). SETTING COMPONENT COLOUR We
can set the colour of a JComponent
by using the setBackground(Color) method. The
following line makes a JButton btn
blue. btn.setBackground(Color.blue); The
following image shows a blue JButton and a green JTextField. OTHER TYPES OF LISTENERS Other
than ActionListeners, there are other types of
Listeners such as ItemListener. They work in a very similar way as ActionListener but are triggered at different times. For example, some may be triggered if the
component is clicked on, some if the component changes states and some at
many times when the component is being altered. |
|