Class MultiInput<C extends JComponent,T>

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
is.codion.swing.common.ui.component.multi.MultiInput<C,T>
Type Parameters:
C - the wrapped component type
T - the value type
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public final class MultiInput<C extends JComponent,T> extends JPanel
A field collecting a set of values through a wrapped component: the wrapped component, untouched, beside a button showing how many values have been collected, the button toggling a non-modal, undecorated dialog listing them under the field, the caption as its border's title. The dialog stays when the focus goes elsewhere, so that the values collected remain on display while more are added, follows the field around and goes when the field does.
  • KeyEvent.VK_INSERT adds the wrapped component's value to the set and clears the component, as does KeyEvent.VK_ENTER while the component holds a value, see MultiInput.Builder.addOnEnter(boolean); an Enter the field does not use is the wrapped component's.
  • KeyEvent.VK_DOWN with Alt held, or the button, opens the dialog, the list in it focused, or moves the focus to the list in case the dialog is already open. KeyEvent.VK_UP with Alt held, or the button, closes it.
  • In the dialog KeyEvent.VK_DELETE removes the selected values, the Clear button clears the set, KeyEvent.VK_UP with Alt held moves the focus back to the field, leaving the dialog open, for adding further values, and KeyEvent.VK_ESCAPE or KeyEvent.VK_ENTER closes it. Alt held, Down and Up thereby step from the field, into the list, and back out again, opening the dialog on the way in and closing it on the way out.
The value is the set collected, sorted, see MultiInput.Builder.comparator(Comparator), plus whatever the wrapped component holds, last, so a single value typed into the component counts without being added. Setting the value sets the collected values and clears the wrapped component. The wrapped component keeps every key of its own.
See Also: