
10.14 Graphics Using Swing Components
Example 10.9: Program to demonstrate JComboBox class
1. import javax.swing.*;
2. public class SwingDemo {
3. public static void main(String[] args) {
4. JFrame frame = new DisplayFrame();
5. frame.setVisible(true);
6. }
7. }
8. class DisplayFrame extends JFrame{
9. DisplayFrame(){
10. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
11. setTitle(“Swing Demo”);
12. setSize(300, 150);
13. setLocation(100,100);
14. JPanel panel = new DisplayPanel();
15. getContentPane().add(panel);
16. }
17. }
18. class DisplayPanel extends JPanel{
19. DisplayPanel() {
20. String[] cities = { “Delhi”, “London”, “New York”, ...