|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object charva.awt.Component charvax.swing.JComponent charvax.swing.JTable
JTable is a user-interface component that displays data in a two- dimensional table format.
The user-interface works as follows:
The user can select a column by pressing the left or right arrow keys
to move to the desired column, and then pressing ENTER.
He/she can select a row by pressing the up and down arrow keys to move to
the desired row, then pressing ENTER.
Depending on the value of the selection mode, multiple rows and/or columns
may be selected. By default the selection mode is set to SINGLE_SELECTION
so that only a single row or column can be selected at a time. Selection
of rows and/or columns can be enabled/disabled by means of the
setRowSelectionAllowed() and setColumnSelectionAllowed() methods.
Field Summary | |
protected ListSelectionModel |
_columnSelectionModel
|
protected ListSelectionModel |
_rowSelectionModel
|
Fields inherited from class charvax.swing.JComponent |
_border |
Fields inherited from class charva.awt.Component |
_alignmentX, _alignmentY, _background, _cursesColor, _enabled, _focusListeners, _foreground, _keyListeners, _origin, _parent, _visible, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Constructor Summary | |
JTable()
Default constructor |
|
JTable(int numRows_,
int numColumns_)
Constructs a table of numRows_ and numColumns_ of empty cells using a DefaultTableModel. |
|
JTable(java.lang.Object[][] data_,
java.lang.Object[] columnNames_)
Construct a JTable from the specified data and column names, using a DefaultTableModel. |
|
JTable(TableModel model_)
Construct a JTable with the specified data model. |
Method Summary | |
void |
addColumnSelectionInterval(int index0_,
int index1_)
Adds the columns from index0_ to index1_ ,
inclusive, to the current selection. |
void |
addRowSelectionInterval(int index0_,
int index1_)
Adds the rows from index0_ to index1_ ,
inclusive, to the current selection. |
void |
addScrollListener(ScrollListener sl_)
Register a ScrollListener object for this table. |
void |
debug(int level_)
|
void |
draw()
Draws the border of the component (if there is one). |
boolean |
getColumnSelectionAllowed()
Returns true if columns can be selected; otherwise false. |
int |
getHeight()
|
TableModel |
getModel()
|
Dimension |
getPreferredScrollableViewportSize()
|
boolean |
getRowSelectionAllowed()
Returns true if rows can be selected; otherwise false. |
int |
getSelectedColumn()
Returns the index of the first selected column, or -1 if no column is selected. |
int |
getSelectedColumnCount()
Returns the number of selected columns. |
int[] |
getSelectedColumns()
Returns an array of the indices of all selected columns. |
int |
getSelectedRow()
Returns the index of the first selected row, or -1 if no row is selected. |
int |
getSelectedRowCount()
Returns the number of selected rows. |
int[] |
getSelectedRows()
Returns an array of the indices of all selected rows. |
int |
getSelectionMode()
Returns the table's row/column selection mode. |
ListSelectionModel |
getSelectionModel()
Returns the table's row selection model. |
Dimension |
getSize()
|
java.lang.Object |
getValueAt(int row_,
int column_)
|
int |
getWidth()
|
boolean |
isColumnSelected(int column_)
Returns true if the column with the specified index is selected. |
boolean |
isRowSelected(int row_)
Returns true if the row with the specified index is selected. |
Dimension |
minimumSize()
|
void |
processKeyEvent(KeyEvent ke_)
Processes key events occurring on this object |
void |
processScrollEvent(ScrollEvent e_)
Process scroll events generated by this JTable. |
void |
removeScrollListener(ScrollListener sl_)
Remove a ScrollListener object that is registered for this table. |
void |
requestFocus()
This method should be invoked by all subclasses of Component which override this method; because this method generates the FOCUS_GAINED event when the component gains the keyboard focus. |
void |
setColumnSelectionAllowed(boolean allowed_)
Set whether selection of columns is allowed. |
void |
setColumnSelectionInterval(int index0_,
int index1_)
Selects the columns from index0_ to index1_ ,
inclusive. |
void |
setModel(TableModel model_)
Sets the data model to the specified TableModel and registers with it as a listener for events from the model. |
void |
setPreferredScrollableViewportSize(Dimension size_)
|
void |
setRowSelectionAllowed(boolean allowed_)
Set whether selection of rows is allowed. |
void |
setRowSelectionInterval(int index0_,
int index1_)
Selects the rows from index0_ to index1_ ,
inclusive. |
void |
setSelectionMode(int mode_)
Sets the table's selection mode to allow selection of either single rows and/or columns, or multiple rows and/or columns. |
void |
setSelectionModel(ListSelectionModel model_)
Sets the table's row selection model and registers for notifications from the new selection model. |
void |
setValueAt(java.lang.Object object_,
int row_,
int column_)
|
void |
tableChanged(TableModelEvent evt_)
This method implements the TableModelListener interface; it is invoked when this table's TableModel generates a TableModelEvent. |
void |
valueChanged(ListSelectionEvent e_)
This method is invoked when the row selection changes. |
Methods inherited from class charvax.swing.JComponent |
getBorder, getInsets, setBorder |
Methods inherited from class charva.awt.Component |
addFocusListener, addKeyListener, contains, contains, getAlignmentX, getAlignmentY, getAncestorWindow, getBackground, getBounds, getCursesColor, getForeground, getLocation, getLocationOnScreen, getName, getParent, hasFocus, hide, invalidate, isDisplayed, isEnabled, isFocusTraversable, isTotallyObscured, isValid, isVisible, processEvent, processFocusEvent, processMouseEvent, repaint, requestSync, setBackground, setBounds, setBounds, setBounds, setEnabled, setForeground, setLocation, setLocation, setName, setParent, setVisible, show, validate, validateCursesColor |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface charva.awt.Scrollable |
getLocation |
Field Detail |
protected ListSelectionModel _rowSelectionModel
protected ListSelectionModel _columnSelectionModel
Constructor Detail |
public JTable()
public JTable(int numRows_, int numColumns_)
public JTable(java.lang.Object[][] data_, java.lang.Object[] columnNames_)
public JTable(TableModel model_)
Method Detail |
public void setModel(TableModel model_)
public TableModel getModel()
public void setValueAt(java.lang.Object object_, int row_, int column_)
public java.lang.Object getValueAt(int row_, int column_)
public void tableChanged(TableModelEvent evt_)
tableChanged
in interface TableModelListener
public void requestFocus()
Component
requestFocus
in class Component
public void draw()
JComponent
draw
in class JComponent
public void processKeyEvent(KeyEvent ke_)
processKeyEvent
in class Component
public void addScrollListener(ScrollListener sl_)
addScrollListener
in interface Scrollable
public void removeScrollListener(ScrollListener sl_)
removeScrollListener
in interface Scrollable
public void processScrollEvent(ScrollEvent e_)
processScrollEvent
in interface Scrollable
public Dimension getSize()
getSize
in class Component
public Dimension minimumSize()
minimumSize
in class Component
public int getWidth()
getWidth
in class Component
public int getHeight()
getHeight
in class Component
public void setPreferredScrollableViewportSize(Dimension size_)
public Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
in interface Scrollable
public void setSelectionModel(ListSelectionModel model_)
public ListSelectionModel getSelectionModel()
public void setSelectionMode(int mode_)
mode_
- the selection mode. Allowable values are
ListSelectionModel.SINGLE_SELECTION and
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION.public int getSelectionMode()
public void setColumnSelectionAllowed(boolean allowed_)
public boolean getColumnSelectionAllowed()
public void setRowSelectionAllowed(boolean allowed_)
public boolean getRowSelectionAllowed()
public void addColumnSelectionInterval(int index0_, int index1_)
index0_
to index1_
,
inclusive, to the current selection.
public void addRowSelectionInterval(int index0_, int index1_)
index0_
to index1_
,
inclusive, to the current selection.
public void setColumnSelectionInterval(int index0_, int index1_)
index0_
to index1_
,
inclusive.
public void setRowSelectionInterval(int index0_, int index1_)
index0_
to index1_
,
inclusive.
public int getSelectedRow()
public int getSelectedRowCount()
public int[] getSelectedRows()
public int getSelectedColumn()
public int getSelectedColumnCount()
public int[] getSelectedColumns()
public boolean isRowSelected(int row_)
public boolean isColumnSelected(int column_)
public void valueChanged(ListSelectionEvent e_)
valueChanged
in interface ListSelectionListener
public void debug(int level_)
debug
in class Component
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |