public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { if (lastSortedColumn == column) ascending = !ascending; sorter.sortByColumn(column, ascending); lastSortedColumn = column; } } };
JTable table = ...; TableModel model = ...; int viewRow = table.getSelectedRow(); int modelRow = table.convertRowIndexToModel(viewRow); int viewColumn = table.getSelectedColumn(); int modelColumn = table.convertColumnIndexToModel(viewColumn); Object cell = model.getValueAt( modelRow, modelColumn );
@Override public void run() { row = table.convertRowIndexToModel( table.getEditingRow() ); column = table.convertColumnIndexToModel( table.getEditingColumn() ); oldValue = table.getModel().getValueAt(row, column); newValue = null; }
public static void saveColumnWidthAndOrderToPrefs(JTable table, String widthPrefKey, String orderPrefKey) { StringBuilder columnWidthSettings = new StringBuilder(); StringBuilder columnOrderSettings = new StringBuilder(); boolean firstValue = true; for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) { TableColumn column = table.getColumnModel().getColumn(table.convertColumnIndexToView(i)); if (!firstValue) { columnWidthSettings.append(','); columnOrderSettings.append(','); } else { firstValue = false; } columnWidthSettings.append(column.getWidth()); columnOrderSettings.append(table.convertColumnIndexToModel(i)); } PreferencesDialog.saveValue(widthPrefKey, columnWidthSettings.toString()); PreferencesDialog.saveValue(orderPrefKey, columnOrderSettings.toString()); }
@Override public void mousePressed(MouseEvent e) { TableColumnModel columnModel = table.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = table.convertColumnIndexToModel(viewColumn); if (column != -1) { // sort ascending boolean asc = true; if (recentSortedColumn == column) { asc = !recentAscending; } sortSetting.setSortIndex(column); sortSetting.setAscending(asc); sort(column, asc); fireTableDataChanged(); } } };
public TableCellRenderer getCellRenderer(int row, int column) { editingClass = null; int modelColumn = convertColumnIndexToModel(column); if (modelColumn == 1) { Class rowClass = getModel().getValueAt(row, modelColumn).getClass(); public TableCellEditor getCellEditor(int row, int column) { editingClass = null; int modelColumn = convertColumnIndexToModel(column); if (modelColumn == 1) { editingClass = getModel().getValueAt(row, modelColumn).getClass();
/** * Gets the sorting style currently applied to the specified column. */ @Override protected final int getSortingStyle(int column) { return super.getSortingStyle(table.convertColumnIndexToModel(column)); }
/** * Gets the sorting style currently applied to the specified column. */ @Override protected final int getSortingStyle(int column) { return super.getSortingStyle(table.convertColumnIndexToModel(column)); }
public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { if (lastSortedColumn == column) ascending = !ascending; sorter.sortByColumn(column, ascending); lastSortedColumn = column; } } };
public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { if (lastSortedColumn == column) ascending = !ascending; sorter.sortByColumn(column, ascending); lastSortedColumn = column; } } };
public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { if (lastSortedColumn == column) ascending = !ascending; sorter.sortByColumn(column, ascending); lastSortedColumn = column; } } };
public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { if (lastSortedColumn == column) ascending = !ascending; sorter.sortByColumn(column, ascending); lastSortedColumn = column; } } };
public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = table.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = table.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { setSortedBy(column); } } };
public void mouseClicked(MouseEvent e) { JTableHeader header = (JTableHeader) e.getSource(); Point point = e.getPoint(); int col = header.columnAtPoint(point); int sortCol = header.getTable().convertColumnIndexToModel(col); sortByColumn(sortCol, true); } });
public void mouseClicked(MouseEvent e) { JTableHeader header = (JTableHeader)(e.getSource()); JTable tableView = header.getTable(); TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (column == 0 && viewColumn == column && e.getClickCount() == 1) { checkAllCheckbox.doClick(); } header.repaint(); } };
public void mouseClicked(MouseEvent e) { JTableHeader header = (JTableHeader)(e.getSource()); JTable tableView = header.getTable(); TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (column == 0 && viewColumn == column && e.getClickCount() == 1) { checkAllCheckbox.doClick(); } header.repaint(); } };
public void mouseClicked(MouseEvent e) { JTableHeader header = (JTableHeader)(e.getSource()); JTable tableView = header.getTable(); TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (column == 0 && viewColumn == column && e.getClickCount() == 1) { checkAllCheckbox.doClick(); } header.repaint(); } };
@Override public void run() { this.row = this.table.convertRowIndexToModel(this.table.getEditingRow()); this.column = this.table.convertColumnIndexToModel(this.table.getEditingColumn()); this.oldValue = this.table.getModel().getValueAt(this.row, this.column); this.newValue = null; } }
@Override public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = fTable.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = fTable.convertColumnIndexToModel(viewColumn); if (MouseUtils.isLeftClick(e) && !e.isAltDown() && !e.isControlDown() && (column != -1)) fModel.sort(column, !e.isShiftDown()); } };
@Override public void mouseMoved(MouseEvent e) { Point point = e.getPoint(); int pointedColumn = jTable1.columnAtPoint(point); if (jTable1.convertColumnIndexToModel(pointedColumn) == 0) { jTable1.setCursor(new Cursor(Cursor.HAND_CURSOR)); } else { jTable1.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }