use of javax.swing.table.AbstractTableModel in project intellij-community by JetBrains.
the class ImportLayoutPanel method moveRowDown.
private void moveRowDown() {
int selected = myImportLayoutTable.getSelectedRow();
if (selected >= myImportLayoutList.getEntryCount() - 1) {
return;
}
TableUtil.stopEditing(myImportLayoutTable);
PackageEntry entry = myImportLayoutList.getEntryAt(selected);
PackageEntry nextEntry = myImportLayoutList.getEntryAt(selected + 1);
myImportLayoutList.setEntryAt(nextEntry, selected);
myImportLayoutList.setEntryAt(entry, selected + 1);
AbstractTableModel model = (AbstractTableModel) myImportLayoutTable.getModel();
model.fireTableRowsUpdated(selected, selected + 1);
myImportLayoutTable.setRowSelectionInterval(selected + 1, selected + 1);
}
use of javax.swing.table.AbstractTableModel in project intellij-community by JetBrains.
the class EditMigrationDialog method addRow.
private void addRow() {
EditMigrationEntryDialog dialog = new EditMigrationEntryDialog(myProject);
MigrationMapEntry entry = new MigrationMapEntry();
dialog.setEntry(entry);
if (!dialog.showAndGet()) {
return;
}
dialog.updateEntry(entry);
myMigrationMap.addEntry(entry);
AbstractTableModel model = (AbstractTableModel) myTable.getModel();
model.fireTableRowsInserted(myMigrationMap.getEntryCount() - 1, myMigrationMap.getEntryCount() - 1);
myTable.setRowSelectionInterval(myMigrationMap.getEntryCount() - 1, myMigrationMap.getEntryCount() - 1);
}
use of javax.swing.table.AbstractTableModel in project intellij-community by JetBrains.
the class EditMigrationDialog method removeRow.
private void removeRow() {
int selected = myTable.getSelectedRow();
if (selected < 0)
return;
myMigrationMap.removeEntryAt(selected);
AbstractTableModel model = (AbstractTableModel) myTable.getModel();
model.fireTableRowsDeleted(selected, selected);
if (selected >= myMigrationMap.getEntryCount()) {
selected--;
}
if (selected >= 0) {
myTable.setRowSelectionInterval(selected, selected);
}
}
use of javax.swing.table.AbstractTableModel in project intellij-community by JetBrains.
the class EditMigrationDialog method moveDown.
private void moveDown() {
int selected = myTable.getSelectedRow();
if (selected >= myMigrationMap.getEntryCount() - 1)
return;
MigrationMapEntry entry = myMigrationMap.getEntryAt(selected);
MigrationMapEntry nextEntry = myMigrationMap.getEntryAt(selected + 1);
myMigrationMap.setEntryAt(nextEntry, selected);
myMigrationMap.setEntryAt(entry, selected + 1);
AbstractTableModel model = (AbstractTableModel) myTable.getModel();
model.fireTableRowsUpdated(selected, selected + 1);
myTable.setRowSelectionInterval(selected + 1, selected + 1);
}
use of javax.swing.table.AbstractTableModel in project jdk8u_jdk by JetBrains.
the class ImageableAreaTest method createAuthorTable.
private static JTable createAuthorTable(int rows) {
final String[] headers = { "Book", "Title" };
final Object[][] data = new Object[rows][2];
for (int i = 0; i < rows; i++) {
int n = i + 1;
data[i] = new Object[] { "Book: " + n, "Title: " + n };
}
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() {
return headers.length;
}
public int getRowCount() {
return data.length;
}
public Object getValueAt(int row, int col) {
return data[row][col];
}
public String getColumnName(int column) {
return headers[column];
}
public Class getColumnClass(int col) {
return getValueAt(0, col).getClass();
}
public void setValueAt(Object aValue, int row, int column) {
data[row][column] = aValue;
}
public boolean isCellEditable(int row, int col) {
return false;
}
};
JTable table = new JTable(dataModel);
table.setGridColor(Color.BLUE);
table.setBackground(Color.WHITE);
table.setForeground(Color.BLACK);
table.setSize(600, 800);
frame = new JFrame();
frame.setSize(400, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(table);
frame.setVisible(true);
return table;
}
Aggregations