Podcast
Questions and Answers
In which package are Swing components defined?
In which package are Swing components defined?
The super class of all swing buttons is –
The super class of all swing buttons is –
Which of the following alignment is not possible for JLabel?
Which of the following alignment is not possible for JLabel?
Alignment constants of JLabel are part of –
Alignment constants of JLabel are part of –
Signup and view all the answers
How will you set an icon for the JLabel?
How will you set an icon for the JLabel?
Signup and view all the answers
Swing's text field is encapsulated by –
Swing's text field is encapsulated by –
Signup and view all the answers
How to give number of columns for JTextField?
How to give number of columns for JTextField?
Signup and view all the answers
What is the return type of getText() method of JButton class?
What is the return type of getText() method of JButton class?
Signup and view all the answers
How will you assign the string and icon both to the JButton?
How will you assign the string and icon both to the JButton?
Signup and view all the answers
Which event is generated when a JButton is pushed?
Which event is generated when a JButton is pushed?
Signup and view all the answers
Immediate super class of JCheckBox is –
Immediate super class of JCheckBox is –
Signup and view all the answers
The constructor JCheckBox(true, 'YES') suggests that –
The constructor JCheckBox(true, 'YES') suggests that –
Signup and view all the answers
When JCheckBox is clicked, which event is generated?
When JCheckBox is clicked, which event is generated?
Signup and view all the answers
How can we create Radio buttons?
How can we create Radio buttons?
Signup and view all the answers
How to make the group of Radio buttons?
How to make the group of Radio buttons?
Signup and view all the answers
How to put the contents of the whole vector into the JComboBox?
How to put the contents of the whole vector into the JComboBox?
Signup and view all the answers
How to prevent the drop-down list of JComboBox?
How to prevent the drop-down list of JComboBox?
Signup and view all the answers
Which method is used to define the tabs in the tabbed pane?
Which method is used to define the tabs in the tabbed pane?
Signup and view all the answers
The scroll bar constants for scroll pane are defined in –
The scroll bar constants for scroll pane are defined in –
Signup and view all the answers
Which of the following constants shows scroll bars always?
Which of the following constants shows scroll bars always?
Signup and view all the answers
JScrollPane is an immediate sub-class of –
JScrollPane is an immediate sub-class of –
Signup and view all the answers
Is it possible to add an array of objects to trees? How?
Is it possible to add an array of objects to trees? How?
Signup and view all the answers
Which items can't we directly add to JTree using its constructor?
Which items can't we directly add to JTree using its constructor?
Signup and view all the answers
When a tree is expanded, which event is generated?
When a tree is expanded, which event is generated?
Signup and view all the answers
Which method is used to translate a mouse click on a specific point of the tree to a tree path?
Which method is used to translate a mouse click on a specific point of the tree to a tree path?
Signup and view all the answers
The TreeNode is –
The TreeNode is –
Signup and view all the answers
The TreeExpansionEvent class is defined in –
The TreeExpansionEvent class is defined in –
Signup and view all the answers
The TreeExpansionListener interface provides the following method –
The TreeExpansionListener interface provides the following method –
Signup and view all the answers
Study Notes
Swing Components and Classes
- Swing components are defined in the
javax.swing
package. - The superclass of all Swing buttons is
AbstractButton
. - JLabel cannot have a TOP alignment option; only LEFT, CENTER, and LEADING are valid alignments.
- Alignment constants for JLabel are part of the
SwingConstants
interface.
JLabel and JTextField
- To set an icon for JLabel, use the
setIcon()
method. - Swing's text field is encapsulated by the
JTextComponent
class. - Number of columns for
JTextField
can be defined using thesetColumns()
method or directly within the constructor.
JButton Functionalities
- The return type of
getText()
method from the JButton class isString
. - To assign both string and icon to a JButton, use the
setIconText()
method. - Pushing a JButton generates an
ActionEvent
.
JCheckBox and Radio Buttons
- The immediate superclass of
JCheckBox
isJToggleButton
. - Constructor
JCheckBox(true, "YES")
indicates that the checkbox is selected and displays "YES". - Clicking a JCheckBox generates an
ItemEvent
. - Radio buttons are created using the
JRadioButton
class and grouped with theButtonGroup
class.
JComboBox and ScrollPane
- To add content from a whole vector into a JComboBox, use the JComboBox constructor.
- To prevent a JComboBox drop-down list, use a method specifically created for prevention or effects within the constructor.
- Tabs in the tabbed pane are defined using the
addTab()
method. - Scroll bar constants for a scroll pane are defined in the
ScrollPaneConstants
class. -
HORIZONTAL_SCROLLBAR_ALWAYS
shows horizontal scroll bars at all times.
JScrollPane and JTree
- JScrollPane is an immediate subclass of
JComponent
. - Adding an array of objects to trees is possible using a specific form of the constructor.
- Directly adding arrays to JTree using its constructor is not possible, while vectors and hash tables can be added.
- Expanding a tree generates a
TreeExpansionEvent
.
TreeNode and Event Handling
-
TreeNode
is an interface. - The
TreeExpansionEvent
class is defined in thejavax.swing.event
package. - The
TreeExpansionListener
interface includes thetreeExpanded()
method.
Miscellaneous
- Handling mouse clicks on a specific point of the tree can be interpreted to a tree path using the
getPathForLocation()
method.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge on Swing components in Java with this assignment. You'll be quizzed on the various classes, packages, and functionalities associated with Java Swing. Perfect for AJP course students!