📄 jtable.java
字号:
// This method does nothing. See API comments. } /** * Returns the bounds of the cell relative to its table. * * @return the bounds of the cell relative to its table */ public Rectangle getBounds() { return table.getCellRect(row, column, true); } /** * The bounds of the table cells cannot be manipulated directly, so * this method does nothing. * * @param rectangle not used */ public void setBounds(Rectangle rectangle) { // This method does nothing. See API comments. } /** * Returns the size of the table cell. * * @return the size of the table cell */ public Dimension getSize() { Rectangle cellRect = table.getCellRect(row, column, true); return new Dimension(cellRect.width, cellRect.height); } /** * The size cannot be set on table cells directly, so this method does * nothing. * * @param dimension not used */ public void setSize(Dimension dimension) { // This method does nothing. See API comments. } /** * Table cells have no children, so we return <code>null</code> here. * * @return <code>null</code> */ public Accessible getAccessibleAt(Point point) { return null; } /** * Returns <code>true</code> if this table cell is focus traversable, * <code>false</code> otherwise. * * @return <code>true</code> if this table cell is focus traversable, * <code>false</code> otherwise */ public boolean isFocusTraversable() { return table.isFocusable(); } /** * Requests that this table cell gets the keyboard focus. */ public void requestFocus() { // We first set the selection models' lead selection to this cell. table.getColumnModel().getSelectionModel() .setLeadSelectionIndex(column); table.getSelectionModel().setLeadSelectionIndex(row); // Now we request that the table receives focus. table.requestFocus(); } /** * Adds a focus listener to this cell. The focus listener is really * added to the table, so there is no way to find out when an individual * cell changes the focus. * * @param listener the focus listener to add */ public void addFocusListener(FocusListener listener) { table.addFocusListener(listener); } /** * Removes a focus listener from the cell. The focus listener is really * removed from the table. * * @param listener the listener to remove */ public void removeFocusListener(FocusListener listener) { table.removeFocusListener(listener); } } protected class AccessibleJTableModelChange implements AccessibleTableModelChange { protected int type; protected int firstRow; protected int lastRow; protected int firstColumn; protected int lastColumn; protected AccessibleJTableModelChange(int type, int firstRow, int lastRow, int firstColumn, int lastColumn) { this.type = type; this.firstRow = firstRow; this.lastRow = lastRow; this.firstColumn = firstColumn; this.lastColumn = lastColumn; } public int getType() { return type; } public int getFirstRow() { return firstRow; } public int getLastRow() { return lastRow; } public int getFirstColumn() { return firstColumn; } public int getLastColumn() { return lastColumn; } } /** * Creates a new <code>AccessibleJTable</code>. * * @since JDK1.5 */ protected AccessibleJTable() { getModel().addTableModelListener(this); getSelectionModel().addListSelectionListener(this); getColumnModel().addColumnModelListener(this); getCellEditor().addCellEditorListener(this); } /** * Returns the number of selected items in this table. */ public int getAccessibleSelectionCount() { return getSelectedColumnCount(); } public Accessible getAccessibleSelection(int i) { // TODO Auto-generated method stub return null; } public boolean isAccessibleChildSelected(int i) { // TODO Auto-generated method stub return false; } public void addAccessibleSelection(int i) { // TODO Auto-generated method stub } public void removeAccessibleSelection(int i) { // TODO Auto-generated method stub } public void clearAccessibleSelection() { // TODO Auto-generated method stub } public void selectAllAccessibleSelection() { // TODO Auto-generated method stub } public void valueChanged(ListSelectionEvent event) { // TODO Auto-generated method stub } /** * Receives notification when the table model changes. Depending on the * type of change, this method calls {@link #tableRowsInserted} or * {@link #tableRowsDeleted}. * * @param event the table model event */ public void tableChanged(TableModelEvent event) { switch (event.getType()) { case TableModelEvent.INSERT: tableRowsInserted(event); break; case TableModelEvent.DELETE: tableRowsDeleted(event); break; } } /** * Receives notification when one or more rows have been inserted into the * table. * * @param event the table model event */ public void tableRowsInserted(TableModelEvent event) { // TODO: What to do here, if anything? This might be a hook method for // subclasses... } /** * Receives notification when one or more rows have been deleted from the * table. * * @param event the table model event */ public void tableRowsDeleted(TableModelEvent event) { // TODO: What to do here, if anything? This might be a hook method for // subclasses... } public void columnAdded(TableColumnModelEvent event) { // TODO Auto-generated method stub } public void columnMarginChanged(ChangeEvent event) { // TODO Auto-generated method stub } public void columnMoved(TableColumnModelEvent event) { // TODO Auto-generated method stub } public void columnRemoved(TableColumnModelEvent event) { // TODO Auto-generated method stub } public void columnSelectionChanged(ListSelectionEvent event) { // TODO Auto-generated method stub } public void editingCanceled(ChangeEvent event) { // TODO Auto-generated method stub } public void editingStopped(ChangeEvent event) { // TODO Auto-generated method stub } /** * Receives notification when any of the JTable's properties changes. This * is used to replace the listeners on the table's model, selection model, * column model and cell editor. * * @param e the property change event */ public void propertyChange(PropertyChangeEvent e) { String propName = e.getPropertyName(); if (propName.equals("tableModel")) { TableModel oldModel = (TableModel) e.getOldValue(); oldModel.removeTableModelListener(this); TableModel newModel = (TableModel) e.getNewValue(); newModel.addTableModelListener(this); } else if (propName.equals("columnModel")) { TableColumnModel oldModel = (TableColumnModel) e.getOldValue(); oldModel.removeColumnModelListener(this); TableColumnModel newModel = (TableColumnModel) e.getNewValue(); newModel.addColumnModelListener(this); } else if (propName.equals("selectionModel")) { ListSelectionModel oldModel = (ListSelectionModel) e.getOldValue(); oldModel.removeListSelectionListener(this); ListSelectionModel newModel = (ListSelectionModel) e.getNewValue(); newModel.addListSelectionListener(this); } else if (propName.equals("cellEditor")) { CellEditor oldEd = (CellEditor) e.getOldValue(); oldEd.removeCellEditorListener(this); CellEditor newEd = (CellEditor) e.getNewValue(); newEd.addCellEditorListener(this); } } public int getAccessibleRow(int index) { // TODO Auto-generated method stub return 0; } public int getAccessibleColumn(int index) { // TODO Auto-generated method stub return 0; } public int getAccessibleIndex(int r, int c) { // TODO Auto-generated method stub return 0; } public Accessible getAccessibleCaption() { // TODO Auto-generated method stub return null; } public void setAccessibleCaption(Accessible caption) { // TODO Auto-generated method stub } public Accessible getAccessibleSummary() { // TODO Auto-generated method stub return null; } public void setAccessibleSummary(Accessible summary) { // TODO Auto-generated method stub } public int getAccessibleRowCount() { // TODO Auto-generated method stub return 0; } public int getAccessibleColumnCount() { // TODO Auto-generated method stub return 0; } public Accessible getAccessibleAt(int r, int c) { // TODO Auto-generated method stub return null; } public int getAccessibleRowExtentAt(int r, int c) { // TODO Auto-generated method stub return 0; } public int getAccessibleColumnExtentAt(int r, int c) { // TODO Auto-generated method stub return 0; } public AccessibleTable getAccessibleRowHeader() { // TODO Auto-generated method stub return null; } public void setAccessibleRowHeader(AccessibleTable header) { // TODO Auto-generated method stub } public AccessibleTable getAccessibleColumnHeader() { // TODO Auto-generated method stub return null; } public void setAccessibleColumnHeader(AccessibleTable header) { // TODO Auto-generated method stub } public Accessible getAccessibleRowDescription(int r) { // TODO Auto-generated method stub return null; } public void setAccessibleRowDescription(int r, Accessible description) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -