bill.util.gui
Class JTableCSV
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JTable
|
+--bill.util.gui.JTableCSV
- All Implemented Interfaces:
- Accessible, ActionListener, CellEditorListener, EventListener, ImageObserver, ListSelectionListener, MenuContainer, MouseListener, Scrollable, Serializable, TableColumnModelListener, TableModelListener
- public class JTableCSV
- extends JTable
- implements ActionListener, MouseListener
JTable widget based on a CSV parser. The parser is used to define the
contents of the table.
- See Also:
- Serialized Form
Fields inherited from class javax.swing.JTable |
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader |
Constructor Summary |
JTableCSV(CSVParser parser)
Creates a new instance using the specified CSV Parser for our associated
table mode. |
Methods inherited from class javax.swing.JTable |
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getTableHeader, getToolTipText, getUI, getUIClassID, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isFocusTraversable, isManagingFocus, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setTableHeader, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit, tableChanged, unconfigureEnclosingScrollPane, updateUI, valueChanged |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus |
JTableCSV
public JTableCSV(CSVParser parser)
- Creates a new instance using the specified CSV Parser for our associated
table mode.
- Parameters:
parser
- The CSV Parser to use with the table model.
setCSVParser
public void setCSVParser(CSVParser parser)
- Sets the CSV Parser for our associated table mode.
- Parameters:
parser
- The CSV Parser to use with the table model.
getCSVParser
public CSVParser getCSVParser()
- Retireves the CSV parser from our assocaited table model.
- Returns:
- The CSV Parser
isColumnEditable
public boolean isColumnEditable()
- Checks to see if the columns of the table are editable. By editable we
mean new columns can be added and existing columns can be deleted.
- Returns:
- Returns
true
if the table's columns are editable,
otherwise returns false
.
setColumnEditable
public void setColumnEditable(boolean editable)
- Sets the table's column editability. When columns are said to be editable
this means new columns can be added to the table and existing ones can
be removed.
- Parameters:
editable
- Value to set the column editability to.
isRowEditable
public boolean isRowEditable()
- Checks to see if the rows of the table are editable. By editable we
mean new rows can be added and existing rows can be deleted.
- Returns:
- Returns
true
if the table's rows are editable,
otherwise returns false
.
setRowEditable
public void setRowEditable(boolean editable)
- Sets the table's row editability. When rows are said to be editable
this means new rows can be added to the table and existing ones can
be removed.
- Parameters:
editable
- Value to set the row editability to.
mousePressed
public void mousePressed(MouseEvent event)
- Called when the user presses down a mouse button on a registered
component. We have registered the JTable component for this purpose.
We want to determine if we need to show a popup menu. We do this by
making sure the correct mouse button was pressed and then determining
the object the mouse cursor is over.
- Specified by:
mousePressed
in interface MouseListener
- Parameters:
event
- The mouse event that caused this method to be called.
mouseReleased
public void mouseReleased(MouseEvent event)
- Called when the user releases a mouse button on a registered
component. We have registered the JTree component for this purpose.
We do not care about release events so the method is empty.
- Specified by:
mouseReleased
in interface MouseListener
- Parameters:
event
- The mouse event that caused this method to be called.
mouseEntered
public void mouseEntered(MouseEvent event)
- Called when the user's mouse cursor enters the area of a registered
component. We have registered the JTree component for this purpose.
We do not care about entry events so the method is empty.
- Specified by:
mouseEntered
in interface MouseListener
- Parameters:
event
- The mouse event that caused this method to be called.
mouseExited
public void mouseExited(MouseEvent event)
- Called when the user's mouse cursor exits the area of a registered
component. We have registered the JTree component for this purpose.
We do not care about entry events so the method is empty.
- Specified by:
mouseExited
in interface MouseListener
- Parameters:
event
- The mouse event that caused this method to be called.
mouseClicked
public void mouseClicked(MouseEvent event)
- Called when the user releases a mouse button on a registered
component. We have registered the JTree component for this purpose.
We do not care about release events so the method is empty.
- Specified by:
mouseClicked
in interface MouseListener
- Parameters:
event
- The mouse event that caused this method to be called.
actionPerformed
public void actionPerformed(ActionEvent actionEvent)
- Called when a popup menu item is selected. Inserts or deletes entries
from the table.
- Specified by:
actionPerformed
in interface ActionListener
- Parameters:
actionEvent
- The event that was performed, i.e. the popup menu
item that was selected.
main
public static void main(String[] argv)
- For testing purposes, creates a GUI that is just a JTableCSV.
- Parameters:
argv
- The first item in the array is used as the file name of
the CSV to display in the table.