
9.16 Graphics Using AWT Controls
20. city.addItemListener(this);
21. }
22. public void paint(Graphics g){
23. g.drawString(city.getSelectedItem(),10, 70);
24. }
25. public void itemStateChanged(ItemEvent e) {
26. repaint();
27. }
28. }
9.3.8 Lists
The difference between choice and list is that in list component we can have multiple selec-
tions. In addition, we can display several items on the display area. The constructors for list
component are
• List(); // only one item can be selected
• List( int rows); // rows will be displayed. Others can be scrolled
• List( int rows , boolean ms); // multiple select can be done.
It may be noted that ...