java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.bzdev.ecdb.InputTablePane
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
Table pane for inputing data.
This class creates a JPanel containing a JTable plus some controls.
The class
InputTablePane.ColSpec
specifies each column in
the table, indicating a title, how the cells in the column are rendered,
and how the cells in the column are edited (a null editor indicates that
the column is a read-only column).
There are methods for determining the number of rows and columns in the table and for obtaining the values at any given cell, and to create dialog boxes containing this panel or a new instance of this panel.
The table model for this panel's table is initialized by providing a
Vector
whose type is
Vector<Vector<Object>>, with the Vector<Object>
representing the rows.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Specification for a table column.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
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
FieldsModifier and TypeFieldDescriptionstatic final int
The value returned byshowDialog(Component,String,InputTablePane)
when the dialog's CANCEL button is pressed.static final int
The value returned byshowDialog(Component,String,InputTablePane)
when the dialog's OK button is pressed.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
Fields inherited from class java.awt.Component
accessibleContext, 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
ConstructorsConstructorDescriptionInputTablePane
(InputTablePane.ColSpec[] colspec, int nrows, boolean canAdd, boolean canDel, boolean canMove) Constructor.InputTablePane
(InputTablePane.ColSpec[] colspec, int nrows, Vector<Vector<Object>> initialRows, boolean canAdd, boolean canDel, boolean canMove) Constructor with explicitly provided rows, possibly followed by blank rows.InputTablePane
(InputTablePane.ColSpec[] colspec, Vector<Vector<Object>> rows, boolean canAdd, boolean canDel, boolean canMove) Constructor based on explicitly provided rows. -
Method Summary
Modifier and TypeMethodDescriptionint
Get the number of columns in the table.int
Get the number of rows in the table.getValueAt
(int rowIndex, int columnIndex) Get the value of a table cell for this table.static int
showDialog
(Component parent, String title, InputTablePane ipane) Show a dialog containing an InputTablePanestatic InputTablePane
showDialog
(Component parent, String title, InputTablePane.ColSpec[] colspec, int nrows, boolean canAdd, boolean canDel, boolean canMove) Create a new InputTablePane inside a dialog.static InputTablePane
showDialog
(Component parent, String title, InputTablePane.ColSpec[] colspec, int nrows, Vector<Vector<Object>> initialRows, boolean canAdd, boolean canDel, boolean canMove) Create a new InputTablePane, initializing some rows, placing the table inside a dialog.static InputTablePane
showDialog
(Component parent, String title, InputTablePane.ColSpec[] colspec, Vector<Vector<Object>> initialRows, boolean canAdd, boolean canDel, boolean canMove) Create a new InputTablePane, initializing some rows, placing the table inside a dialog.void
Stop editing a cell.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
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 Details
-
OK
public static final int OKThe value returned byshowDialog(Component,String,InputTablePane)
when the dialog's OK button is pressed.- See Also:
-
CANCEL
public static final int CANCELThe value returned byshowDialog(Component,String,InputTablePane)
when the dialog's CANCEL button is pressed.- See Also:
-
-
Constructor Details
-
InputTablePane
public InputTablePane(InputTablePane.ColSpec[] colspec, int nrows, boolean canAdd, boolean canDel, boolean canMove) Constructor.- Parameters:
colspec
- an array (one entry per column in column order) specifying a columnnrows
- the number of rowscanAdd
- true if rows can be added to the table; false otherwisecanDel
- true if rows can be deleted from the table; false otherwisecanMove
- true if rows can be moved up or down in the table; false otherwise
-
InputTablePane
public InputTablePane(InputTablePane.ColSpec[] colspec, Vector<Vector<Object>> rows, boolean canAdd, boolean canDel, boolean canMove) Constructor based on explicitly provided rows.- Parameters:
colspec
- an array (one entry per column in column order) specifying a columnrows
- the table's rows as a Vector of rows, where each row contains a vector whose elements fit the specification provided by the first argument (colspec)canAdd
- true if rows can be added to the table; false otherwisecanDel
- true if rows can be deleted from the table; false otherwisecanMove
- true if rows can be moved up or down in the table; false otherwise
-
InputTablePane
public InputTablePane(InputTablePane.ColSpec[] colspec, int nrows, Vector<Vector<Object>> initialRows, boolean canAdd, boolean canDel, boolean canMove) Constructor with explicitly provided rows, possibly followed by blank rows.- Parameters:
colspec
- an array (one entry per column in column order) specifying a columninitialRows
- the table's initial rows as a Vector of rows, where each row contains a vector whose elements fit the specification provided by the first argument (colspec)nrows
- the number of rowscanAdd
- true if rows can be added to the table; false otherwisecanDel
- true if rows can be deleted from the table; false otherwisecanMove
- true if rows can be moved up or down in the table; false otherwise
-
-
Method Details
-
getRowCount
public int getRowCount()Get the number of rows in the table.- Returns:
- the number of rows
-
getColumnCount
public int getColumnCount()Get the number of columns in the table.- Returns:
- the number of tables.
-
getValueAt
Get the value of a table cell for this table.- Parameters:
rowIndex
- the row index (starting at 0)columnIndex
- the column index (starting at 0)- Returns:
- the value for the specified row and column
-
stopCellEditing
public void stopCellEditing()Stop editing a cell. -
showDialog
public static InputTablePane showDialog(Component parent, String title, InputTablePane.ColSpec[] colspec, int nrows, boolean canAdd, boolean canDel, boolean canMove) Create a new InputTablePane inside a dialog.- Parameters:
parent
- the component on which to center the dialogtitle
- the title of the dialogcolspec
- the column specification for the tablenrows
- the number of rows in the tablecanAdd
- true if rows can be added to the table; false otherwisecanDel
- true if rows can be deleted from the table; false otherwisecanMove
- true if rows can be moved up or down in the table; false otherwise
-
showDialog
public static InputTablePane showDialog(Component parent, String title, InputTablePane.ColSpec[] colspec, Vector<Vector<Object>> initialRows, boolean canAdd, boolean canDel, boolean canMove) Create a new InputTablePane, initializing some rows, placing the table inside a dialog.- Parameters:
parent
- the component on which to center the dialogtitle
- the title of the dialogcolspec
- the column specification for the tableinitialRows
- the rows to initially add to the table, which determines the initial number of rows in the table.canAdd
- true if rows can be added to the table; false otherwisecanDel
- true if rows can be deleted from the table; false otherwisecanMove
- true if rows can be moved up or down in the table; false otherwise
-
showDialog
public static InputTablePane showDialog(Component parent, String title, InputTablePane.ColSpec[] colspec, int nrows, Vector<Vector<Object>> initialRows, boolean canAdd, boolean canDel, boolean canMove) Create a new InputTablePane, initializing some rows, placing the table inside a dialog.- Parameters:
parent
- the component on which to center the dialogtitle
- the title of the dialogcolspec
- the column specification for the tableinitialRows
- the rows to initially add to the table, placed as the first rows in the tablenrows
- the number of rows in the tablecanAdd
- true if rows can be added to the table; false otherwisecanDel
- true if rows can be deleted from the table; false otherwisecanMove
- true if rows can be moved up or down in the table; false otherwise
-
showDialog
Show a dialog containing an InputTablePane
-