Unit V Java
Unit V Java
MCQs
Swing Basics
Swing Components
25. Which Swing component allows users to select multiple items from a list?
a) JList
b) JComboBox
c) JTextArea
d) JCheckBox
Answer: a
5-Mark Questions
10-Mark Questions
1. Write a program to create a JFrame with JTextField, JTextArea, and JButton. Implement an
ActionListener to display the text entered in JTextField into JTextArea.
2. Explain the purpose and features of top-level containers in Swing. Provide examples for
JFrame, JDialog, and JWindow.
3. Write a program to create a JComboBox and JList. Display the selected item from
JComboBox into JList.
4. Discuss the purpose of JPanel and layout managers in Swing. Write a program to
demonstrate the use of JPanel with BorderLayout.
5. Write a program to create a scrollable JTextArea using JScrollPane. Explain the code.