Unit IV-Part II - Swing
Unit IV-Part II - Swing
Constructor Description
Methods Description
void setText(String s) It is used to set specified text on
button
String getText() It is used to return the text of the
button.
void setEnabled(boolean b) It is used to enable or disable the
button.
void addActionListener(ActionListener a) It is used to add the action listener
to this object.
The Adapter classes with their corresponding listener interfaces are as follows.
1. Swing Components
MenuBar and MenuItem
2. Layout Manager
BorderLayout
GridLayout
3. Applet
There are the following classes that represent the layout managers:
java.awt.BorderLayout
java.awt.FlowLayout
java.awt.GridLayout
java.awt.CardLayout
java.awt.GridBagLayout
javax.swing.BoxLayout
javax.swing.GroupLayout
javax.swing.ScrollPaneLayout
javax.swing.SpringLayout etc.
GridLayout():
creates a grid layout with one column per component in a row.
GridLayout(int rows, int columns):
creates a grid layout with the given rows and columns but no gaps
between the components.
GridLayout(int rows, int columns, int hgap, int vgap):
creates a grid layout with the given rows and columns along with given
horizontal and vertical gaps.
Thursday, June 27, 2024 25
Example 1