Podcast
Questions and Answers
In which package are Swing components defined?
In which package are Swing components defined?
- javax.swing (correct)
- javax.java.swing
- java.javax.swing
- javax.applet.swing
The super class of all swing buttons is –
The super class of all swing buttons is –
- JButton
- ButtonGroup
- AbstractButton (correct)
- Button
Which of the following alignment is not possible for JLabel?
Which of the following alignment is not possible for JLabel?
- LEFT
- TOP (correct)
- LEADING
- CENTER
Alignment constants of JLabel are part of –
Alignment constants of JLabel are part of –
How will you set an icon for the JLabel?
How will you set an icon for the JLabel?
Swing's text field is encapsulated by –
Swing's text field is encapsulated by –
How to give number of columns for JTextField?
How to give number of columns for JTextField?
What is the return type of getText() method of JButton class?
What is the return type of getText() method of JButton class?
How will you assign the string and icon both to the JButton?
How will you assign the string and icon both to the JButton?
Which event is generated when a JButton is pushed?
Which event is generated when a JButton is pushed?
Immediate super class of JCheckBox is –
Immediate super class of JCheckBox is –
The constructor JCheckBox(true, 'YES') suggests that –
The constructor JCheckBox(true, 'YES') suggests that –
When JCheckBox is clicked, which event is generated?
When JCheckBox is clicked, which event is generated?
How can we create Radio buttons?
How can we create Radio buttons?
How to make the group of Radio buttons?
How to make the group of Radio buttons?
How to put the contents of the whole vector into the JComboBox?
How to put the contents of the whole vector into the JComboBox?
How to prevent the drop-down list of JComboBox?
How to prevent the drop-down list of JComboBox?
Which method is used to define the tabs in the tabbed pane?
Which method is used to define the tabs in the tabbed pane?
The scroll bar constants for scroll pane are defined in –
The scroll bar constants for scroll pane are defined in –
Which of the following constants shows scroll bars always?
Which of the following constants shows scroll bars always?
JScrollPane is an immediate sub-class of –
JScrollPane is an immediate sub-class of –
Is it possible to add an array of objects to trees? How?
Is it possible to add an array of objects to trees? How?
Which items can't we directly add to JTree using its constructor?
Which items can't we directly add to JTree using its constructor?
When a tree is expanded, which event is generated?
When a tree is expanded, which event is generated?
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?
The TreeNode is –
The TreeNode is –
The TreeExpansionEvent class is defined in –
The TreeExpansionEvent class is defined in –
The TreeExpansionListener interface provides the following method –
The TreeExpansionListener interface provides the following method –
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!