|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel org.fife.ui.modifiabletable.ModifiableTable
public class ModifiableTable
A table with "Add," "Remove," and possibly "Modify" buttons.
Basically, the caller provides the table model for the data, along
with a "handler" that is called when adding/editing/removing data
from the model. When you want to retrieve the data back from the
table, you can get it via getDataVector()
.
ModifiableTableListener
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
ADD
|
static int |
ADD_REMOVE
|
static int |
ADD_REMOVE_MODIFY
|
static int |
ALL_BUTTONS
|
static java.lang.String |
BOTTOM
|
static java.lang.String |
LEFT
|
static int |
MODIFY
|
static int |
MOVE_UP_DOWN
|
static java.lang.String |
PROPERTY_PANELS_NON_OPAQUE
If this system property is set to true , then the panels
created containing the buttons ("Add", "Modify", "Remove", etc.) will
be non-opaque. |
static int |
REMOVE
|
static java.lang.String |
RIGHT
|
static java.lang.String |
TOP
|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, 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 | |
---|---|
ModifiableTable(javax.swing.table.DefaultTableModel model)
Creates a ModifiableTable with Add ,
Remove , and Modify buttons below the table. |
|
ModifiableTable(javax.swing.table.DefaultTableModel model,
java.lang.Object[] columnNames)
Creates a ModifiableTable with Add ,
Remove , and Modify buttons below the table. |
|
ModifiableTable(javax.swing.table.DefaultTableModel model,
java.lang.Object[] columnNames,
java.lang.String buttonLocation,
int buttons)
Constructor. |
|
ModifiableTable(javax.swing.table.DefaultTableModel model,
java.lang.Object[] columnNames,
java.lang.String buttonLocation,
int buttons,
java.util.List<? extends javax.swing.Action> customButtons)
Constructor. |
|
ModifiableTable(javax.swing.table.DefaultTableModel model,
java.lang.String buttonLocation,
int buttons)
Constructor. |
|
ModifiableTable(javax.swing.table.DefaultTableModel model,
java.lang.String buttonLocation,
int buttons,
java.util.List<? extends javax.swing.Action> customButtons)
Constructor. |
Method Summary | |
---|---|
void |
addModifiableTableListener(ModifiableTableListener l)
Adds a listener to this modifiable table. |
protected void |
addRow()
Gets information from the user on a new row to add and adds it to the table. |
protected javax.swing.JPanel |
createButtonPanel(java.lang.String buttonLocation,
int buttons,
java.util.List<? extends javax.swing.Action> customButtons)
Returns the panel of buttons for modifying the table. |
protected void |
fireModifiableTableEvent(int change,
int row)
Notifies all listeners of a row being added, removed, or modified. |
java.util.Vector<?> |
getDataVector()
Retrieves the data stored in the table as a Vector of
Vector s. |
int |
getFirstMovableRow()
Returns the "first movable row." |
int |
getSelectedRow()
Returns the currently selected row. |
javax.swing.JTable |
getTable()
Returns the table displayed in this modifiable table. |
protected void |
modifyRow()
Modifies the contents of a row in the table. |
protected void |
moveRow(int amt)
Swaps the selected row with another. |
void |
removeModifiableTableListener(ModifiableTableListener l)
Removes a listener from this modifiable table. |
protected void |
removeRow()
Removes the contents of the selected row in the table. |
void |
setEnabled(boolean enabled)
Toggles whether this modifiable table is enabled. |
void |
setFirstMovableRow(int firstMovableRow)
Sets the "first movable row." |
void |
setRowHandler(RowHandler handler)
Sets the handler used when the user adds or modifies a row in the table. |
void |
updateUI()
Updates the Look and Feel of this table. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI |
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int ADD
public static final int REMOVE
public static final int MODIFY
public static final int ADD_REMOVE
public static final int ADD_REMOVE_MODIFY
public static final int MOVE_UP_DOWN
public static final int ALL_BUTTONS
public static final java.lang.String TOP
public static final java.lang.String BOTTOM
public static final java.lang.String LEFT
public static final java.lang.String RIGHT
public static final java.lang.String PROPERTY_PANELS_NON_OPAQUE
true
, then the panels
created containing the buttons ("Add", "Modify", "Remove", etc.) will
be non-opaque. This is useful on OS's such as Windows XP and Vista,
where tabbed panes have a gradient background. By default this is
false
in case it messes up some other LookAndFeel.
Constructor Detail |
---|
public ModifiableTable(javax.swing.table.DefaultTableModel model)
ModifiableTable
with Add
,
Remove
, and Modify
buttons below the table.
model
- The model to use for the table.setRowHandler(org.fife.ui.modifiabletable.RowHandler)
public ModifiableTable(javax.swing.table.DefaultTableModel model, java.lang.Object[] columnNames)
ModifiableTable
with Add
,
Remove
, and Modify
buttons below the table.
model
- The model to use for the table.columnNames
- Objects to use for names of the columns. This value
can be null
if the model already takes care of its
column names.setRowHandler(org.fife.ui.modifiabletable.RowHandler)
public ModifiableTable(javax.swing.table.DefaultTableModel model, java.lang.String buttonLocation, int buttons)
model
- The model to use for the table.buttonLocation
- The location of the buttons, relative to the
table.buttons
- A bit flag representing what buttons to display.setRowHandler(RowHandler)
,
ADD_REMOVE
,
ADD_REMOVE_MODIFY
,
MOVE_UP_DOWN
,
ALL_BUTTONS
public ModifiableTable(javax.swing.table.DefaultTableModel model, java.lang.String buttonLocation, int buttons, java.util.List<? extends javax.swing.Action> customButtons)
model
- The model to use for the table.buttonLocation
- The location of the buttons, relative to the
table.buttons
- A bit flag representing what buttons to display.customButtons
- A list of Action
s for "extra"
buttons to add. This may be null
if no custom
buttons are to be added.setRowHandler(RowHandler)
,
ADD_REMOVE
,
ADD_REMOVE_MODIFY
,
MOVE_UP_DOWN
,
ALL_BUTTONS
public ModifiableTable(javax.swing.table.DefaultTableModel model, java.lang.Object[] columnNames, java.lang.String buttonLocation, int buttons)
model
- The model to use for the table.columnNames
- Objects to use for names of the columns. This value
can be null
if the model already takes care of its
column names.buttonLocation
- The location of the buttons, relative to the
table.buttons
- A bit flag representing what buttons to display.setRowHandler(org.fife.ui.modifiabletable.RowHandler)
public ModifiableTable(javax.swing.table.DefaultTableModel model, java.lang.Object[] columnNames, java.lang.String buttonLocation, int buttons, java.util.List<? extends javax.swing.Action> customButtons)
model
- The model to use for the table.columnNames
- Objects to use for names of the columns. This value
can be null
if the model already takes care of its
column names.buttonLocation
- The location of the buttons, relative to the
table.buttons
- A bit flag representing what buttons to display.customButtons
- A list of Action
s for "extra"
buttons to add. This may be null
if no custom
buttons are to be added.setRowHandler(org.fife.ui.modifiabletable.RowHandler)
Method Detail |
---|
public void addModifiableTableListener(ModifiableTableListener l)
l
- The listener to add.removeModifiableTableListener(org.fife.ui.modifiabletable.ModifiableTableListener)
protected void addRow()
Add
button.
modifyRow()
,
removeRow()
protected javax.swing.JPanel createButtonPanel(java.lang.String buttonLocation, int buttons, java.util.List<? extends javax.swing.Action> customButtons)
buttonLocation
- The location of the buttons, relative to the
table.buttons
- A bit flag representing what buttons to display.customButtons
- A list of Action
s for "extra"
buttons to add. This may be null
if no custom
buttons are to be added.
protected void fireModifiableTableEvent(int change, int row)
change
- The change that occurred.row
- The row that was added, removed or modified.public java.util.Vector<?> getDataVector()
Vector
of
Vector
s. Each Vector
inside of the
returned Vector
represents a single row.
This method is simply a wrapper for
((DefaultTableModel)getTable().getModel()).getDataVector()
.
public int getFirstMovableRow()
0
, then the rows
0
through getFirstMovableRow()-1
can not be
moved up or down, and other rows cannot be moved up into them.This property is ignored if this modifiable table is not displaying the "move up" and "move down" buttons.
setFirstMovableRow(int)
public int getSelectedRow()
-1
if no
row is selected.public javax.swing.JTable getTable()
protected void modifyRow()
Modify
button.
addRow()
,
removeRow()
protected void moveRow(int amt)
amt
- The offset between the selected row and the row to swap it
with; e.g. "1" or "-1".public void removeModifiableTableListener(ModifiableTableListener l)
l
- The listener to remove.addModifiableTableListener(org.fife.ui.modifiabletable.ModifiableTableListener)
protected void removeRow()
Remove
button.
addRow()
,
modifyRow()
public void setEnabled(boolean enabled)
setEnabled
in class javax.swing.JComponent
enabled
- Whether this modifiable table is enabled.public void setFirstMovableRow(int firstMovableRow)
0
, then the rows
0
through getFirstMovableRow()-1
can not be
moved up or down, and other rows cannot be moved up into them.
Typically, if this is modified, you'll also want to ensure your
RowHandler
forbids the removal of the unmovable rows.
This property is ignored if this modifiable table is not displaying the "move up" and "move down" buttons.
firstMovableRow
- The first movable row. This should be greater
than 0
.getFirstMovableRow()
public void setRowHandler(RowHandler handler)
handler
- The new handler.RowHandler
public void updateUI()
RowHandler
, if it is a Swing component.
updateUI
in class javax.swing.JPanel
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |