| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JComboBox
jas.util.JASEditableComboBox
public final class JASEditableComboBox
This class is ideal if you want to have a text field for user input but also have a list of recently selected items available to choose from. Some notes on using this class:
clickDefault
  is true.  This behaviour may be desirable because
  the default button is normally "clicked" when the user clicks on
  the "Enter" key, but this behaviour doesn't normally happen unless
  you add an ActionListener to the text field.addActionListener(ActionListener) on this
  object causes the ActionListener to be added to the text field.Basically, a ChangeEvent is a dual purpose event. One is sent to listeners both when a KeyEvent is generated from the text field, and one is sent when an ItemEvent is generated (which happens when an item is selected from the drop-down list). This means that somebody who wants to know when the actual text showing has changed only needs to implement ChangeListener instead of both ItemListener and KeyListener.
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from class javax.swing.JComboBox | 
|---|
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager | 
| Nested classes/interfaces inherited from class javax.swing.JComponent | 
|---|
JComponent.AccessibleJComponent | 
| Nested classes/interfaces inherited from class java.awt.Container | 
|---|
Container.AccessibleAWTContainer | 
| Nested classes/interfaces inherited from class java.awt.Component | 
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy | 
| Field Summary | 
|---|
| Fields inherited from class javax.swing.JComboBox | 
|---|
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder | 
| Fields inherited from class javax.swing.JComponent | 
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW | 
| Fields inherited from class java.awt.Component | 
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT | 
| Fields inherited from interface java.awt.image.ImageObserver | 
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH | 
| Constructor Summary | |
|---|---|
JASEditableComboBox(String[] dropDownItems,
                    boolean clickDefault)
Creates a JASEditableComboBox with the given list of drop-down items.  | 
|
JASEditableComboBox(String key,
                    int nItems,
                    boolean clickDefault)
Creates a JASEditableComboBox with a dropDown list that will be stored in the UserProperties object for the Application.  | 
|
JASEditableComboBox(String key,
                    String lengthKey,
                    boolean clickDefault)
Creates a JASEditableComboBox with a dropDown list that will be stored in the UserProperties object for the Application.  | 
|
| Method Summary | |
|---|---|
 void | 
addActionListener(ActionListener l)
Adds an the given ActionListener to the text field.  | 
 void | 
addChangeListener(ChangeListener l)
Change listeners will be notified any time the text visible in the text field changes.  | 
 void | 
addKeyListener(KeyListener kl)
Adds a key listener to the text field, not to the JComboBox.  | 
protected  void | 
fireItemStateChanged(ItemEvent event)
This method is protected as an implementation side effect.  | 
 Dimension | 
getMaximumSize()
Encorporates the maximum width if it has been set.  | 
 Dimension | 
getMinimumSize()
Encorporates the minimum width if it has been set.  | 
 Dimension | 
getPreferredSize()
Encorporates the minimum and maximum widths if they have been set.  | 
 String | 
getText()
Returns the text currently showing in the text field.  | 
 void | 
keyPressed(KeyEvent e)
This method is public as an implementation side effect; do not call.  | 
 void | 
keyReleased(KeyEvent e)
This method is public as an implementation side effect; do not call.  | 
 void | 
keyTyped(KeyEvent e)
This method is public as an implementation side effect; do not call.  | 
 void | 
requestFocus()
Requests focus for the text field of the box.  | 
 void | 
saveState()
If a key was supplied to the constructor, the drop-down list will be updated to include the currently selected item.  | 
 void | 
setMaxWidth(int maxWidth)
Set the maximum width of the box.  | 
 void | 
setMinWidth(int minWidth)
Set the minimum width of the box.  | 
 void | 
setText(String s)
Sets the text showing in the text field.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
|---|
public JASEditableComboBox(String[] dropDownItems,
                           boolean clickDefault)
dropDownItems - the items to show in the drop-down list (can safely be null)clickDefault - whether the default button should be clicked when Enter is pressedJRootPane.defaultButton
public JASEditableComboBox(String key,
                           int nItems,
                           boolean clickDefault)
saveState()
 method to have the list be updated to include the selected item.
key - the key that the drop-down items will be stored bynItems - the maximum number of items that will be stored on the drop-down listclickDefault - whether the default button should be clicked when Enter is pressedUserProperties, 
JRootPane.defaultButton
public JASEditableComboBox(String key,
                           String lengthKey,
                           boolean clickDefault)
saveState()
 method to have the list be updated to include the selected item.
key - the key that the drop-down items will be stored bylengthKey - the key that maps to the maximum number of items that will be stored on the drop-down listclickDefault - whether the default button should be clicked when Enter is pressedUserProperties, 
JRootPane.defaultButton| Method Detail | 
|---|
public void saveState()
public String getText()
public void setText(String s)
public void addKeyListener(KeyListener kl)
addKeyListener in class Componentpublic final void keyReleased(KeyEvent e)
keyReleased in interface KeyListenerpublic final void keyPressed(KeyEvent e)
keyPressed in interface KeyListenerpublic void addChangeListener(ChangeListener l)
l - the ChangeListener to addpublic void addActionListener(ActionListener l)
addActionListener in class JComboBoxprotected final void fireItemStateChanged(ItemEvent event)
fireItemStateChanged in class JComboBoxpublic final void requestFocus()
requestFocus in class JComponentpublic final void keyTyped(KeyEvent e)
keyTyped in interface KeyListenerpublic final void setMaxWidth(int maxWidth)
maxWidth - give a number in pixels, or -1 to use defaultpublic final void setMinWidth(int minWidth)
minWidth - give a number in pixels, or -1 to use defaultpublic final Dimension getMaximumSize()
getMaximumSize in class JComponentsetMaxWidth(int)public final Dimension getMinimumSize()
getMinimumSize in class JComponentsetMinWidth(int)public final Dimension getPreferredSize()
getPreferredSize in class JComponentsetMinWidth(int), 
setMaxWidth(int)
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||