CS 121 Lecture Notes - Lecture 72: Combo Box, Exception Handling
• Combo Boxes:
➢ Allows user to select one of several options from a drop down menu.
➢ When user presses a combo box using the mouse, a list of options is
displayed from which the user can choose.
o Current choice is displayed the combo box.
o Combo box is defined by JComboBox class.
➢ Can be either editable or uneditable.
o By default, a combo box is uneditable.
o Changing the value of an uneditable combo box can be accomplished only
by selecting an item from the list.
➢ If the combo box is editable, user can change value by:
o Selecting an item from the list.
o Typing a particular value into the combo box area.
➢ Options in a combo box list can be established in one of two ways.
o Create an array of strings & pass it into constructor of JComboBox class.
o Use addItem method to add an item to combo box after it has been
created.
▪ A JComboBox can also display ImageIcon objects as options as
well.
➢ Creating URL objects can potentially throw a checked exception; therefore
they are created in a try block.
➢ A combo box generates an action event whenever the user makes a selection
from it.
• Scroll Panes:
➢ A container that offers a limited view of a component.
➢ Provides vertical/horizontal scroll bars to change that view.
find more resources at oneclass.com
find more resources at oneclass.com
Document Summary
Allows user to select one of several options from a (cid:498)drop down(cid:499) menu. When user presses a combo box using the mouse, a list of options is displayed from which the user can choose: current choice is displayed the combo box, combo box is defined by jcombobox class. Can be either editable or uneditable: by default, a combo box is uneditable, changing the value of an uneditable combo box can be accomplished only by selecting an item from the list. If the combo box is editable, user can change value by: selecting an item from the list, typing a particular value into the combo box area. Creating url objects can potentially throw a checked exception; therefore they are created in a try block. A combo box generates an action event whenever the user makes a selection from it: scroll panes: A container that offers a limited view of a component.