Package com.sun.javatest.tool
Class EditableList
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- com.sun.javatest.tool.EditableList
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
- Direct Known Subclasses:
EditableFileList
public class EditableList extends javax.swing.JComponent implements javax.accessibility.Accessible
A component that displays an editable list of items.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.DefaultListModel<java.lang.Object>
listModel
The list model that contains the elements of the list.protected UIFactory
uif
The factory used to create the GUI elements of the component.-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description EditableList()
Create an empty component, using a standard UIFactory for this class, and using resources beginning with "list.".EditableList(UIFactory uif, java.lang.String uiKey)
Create an empty component, using a specified UIFactory and resource prefix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListDataListener(javax.swing.event.ListDataListener l)
Add a listener to be notified of events when the list data changes.void
clear()
Remove all entries from the list.javax.accessibility.AccessibleContext
getAccessibleContext()
Get the accessible context for this pane.protected java.lang.Object
getDisplayValue(java.lang.Object item)
Get the display value for an item in the list.java.lang.Object[]
getItems()
Get the items currently in the list.java.lang.Object[]
getItems(java.lang.Class<?> c)
Get the items currently in the list, in an array of a specific type.protected java.lang.Object
getNewItem()
Invoked to get a new item to put in the list, when the user clicks the "Add" button".protected java.lang.Object
getNewItem(java.lang.Object oldItem)
Invoked to get a new item to replace an existing item in the list.java.lang.String
getToolTipText()
Get the tool tip text that appears on the list.boolean
isDuplicatesAllowed()
Check whether or not duplicates should be allowed in the list.void
removeListDataListener(javax.swing.event.ListDataListener l)
Remove a listener that was previously added to be notified of events when the list data changes.void
setDuplicatesAllowed(boolean b)
Specify whether or not duplicates should be allowed in the list.void
setEnabled(boolean b)
Set whether or not the list can be edited by the user.void
setItems(java.lang.Object... items)
Set the items in the list.void
setToolTipText(java.lang.String tip)
Set the tool tip text that appears on the list.-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
uif
protected final UIFactory uif
The factory used to create the GUI elements of the component.
-
listModel
protected javax.swing.DefaultListModel<java.lang.Object> listModel
The list model that contains the elements of the list.
-
-
Constructor Detail
-
EditableList
public EditableList()
Create an empty component, using a standard UIFactory for this class, and using resources beginning with "list.".
-
EditableList
public EditableList(UIFactory uif, java.lang.String uiKey)
Create an empty component, using a specified UIFactory and resource prefix.- Parameters:
uif
- The UIFactory used to construct the componentuiKey
- The prefix for any UI resources that may be required
-
-
Method Detail
-
getAccessibleContext
public javax.accessibility.AccessibleContext getAccessibleContext()
Get the accessible context for this pane.- Specified by:
getAccessibleContext
in interfacejavax.accessibility.Accessible
- Overrides:
getAccessibleContext
in classjava.awt.Component
- Returns:
- the accessible context for this pane
-
setEnabled
public void setEnabled(boolean b)
Set whether or not the list can be edited by the user.- Overrides:
setEnabled
in classjavax.swing.JComponent
- Parameters:
b
- if true, the component can be edited by the user; if false, it cannot
-
clear
public void clear()
Remove all entries from the list.
-
getItems
public java.lang.Object[] getItems()
Get the items currently in the list.- Returns:
- an array containing the items currently in the list
- See Also:
setItems(java.lang.Object...)
-
setItems
public void setItems(java.lang.Object... items)
Set the items in the list. Any previous items are removed first.- Parameters:
items
- the array of items to be put in the list.- See Also:
getItems()
-
getItems
public java.lang.Object[] getItems(java.lang.Class<?> c)
Get the items currently in the list, in an array of a specific type.- Parameters:
c
- the component type of the array to be returned- Returns:
- an array containing the items currently in the list
- See Also:
setItems(java.lang.Object...)
-
getToolTipText
public java.lang.String getToolTipText()
Get the tool tip text that appears on the list. (Separate tool tip text will appear on the buttons to manipulate the list.)- Overrides:
getToolTipText
in classjavax.swing.JComponent
- Returns:
- the tool tip text that appears on the list
- See Also:
setToolTipText(java.lang.String)
-
setToolTipText
public void setToolTipText(java.lang.String tip)
Set the tool tip text that appears on the list. (Separate tool tip text will appear on the buttons to manipulate the list.)- Overrides:
setToolTipText
in classjavax.swing.JComponent
- Parameters:
tip
- the tool tip text to appear on the list- See Also:
getToolTipText()
-
addListDataListener
public void addListDataListener(javax.swing.event.ListDataListener l)
Add a listener to be notified of events when the list data changes.- Parameters:
l
- the listener to be notified- See Also:
removeListDataListener(javax.swing.event.ListDataListener)
-
removeListDataListener
public void removeListDataListener(javax.swing.event.ListDataListener l)
Remove a listener that was previously added to be notified of events when the list data changes.- Parameters:
l
- the listener to be notified- See Also:
addListDataListener(javax.swing.event.ListDataListener)
-
isDuplicatesAllowed
public boolean isDuplicatesAllowed()
Check whether or not duplicates should be allowed in the list.- Returns:
- true if duplicates should be allowed, and false otherwise
- See Also:
setDuplicatesAllowed(boolean)
-
setDuplicatesAllowed
public void setDuplicatesAllowed(boolean b)
Specify whether or not duplicates should be allowed in the list.- Parameters:
b
- true if duplicates should be allowed, and false otherwise- See Also:
isDuplicatesAllowed()
-
getDisplayValue
protected java.lang.Object getDisplayValue(java.lang.Object item)
Get the display value for an item in the list. By default, the display value is the item itself.- Parameters:
item
- the object for which to get the display value- Returns:
- the display value for the specified item
-
getNewItem
protected java.lang.Object getNewItem()
Invoked to get a new item to put in the list, when the user clicks the "Add" button". The default is to show an input dialog to allow the user to type in a new string. Subtypes may override this method to provide other ways of specifying items to be added, such as a file chooser.- Returns:
- an object to be added to the list, or null if no object to be added.
-
getNewItem
protected java.lang.Object getNewItem(java.lang.Object oldItem)
Invoked to get a new item to replace an existing item in the list. The default is to show an input dialog to allow the user to type in a new string. Subtypes may override this method to provide other ways of specifying items to be added, such as a file chooser.- Parameters:
oldItem
- the item to be replaced in the list- Returns:
- an object to replace the old item the list, or null if no replacement should occur.
-
-