use of javax.swing.table.TableModel in project jdk8u_jdk by JetBrains.
the class bug7055065 method createAndShowUI.
private static void createAndShowUI() {
JFrame frame = new JFrame("SimpleTableDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel newContentPane = new JPanel();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
final String[] columnNames = { "String", "Number" };
final Object[][] data = { { "aaaa", new Integer(1) }, { "bbbb", new Integer(3) }, { "cccc", new Integer(2) }, { "dddd", new Integer(4) }, { "eeee", new Integer(5) } };
table = new JTable(data, columnNames);
table.setPreferredScrollableViewportSize(new Dimension(500, 400));
table.setFillsViewportHeight(true);
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() {
return columnNames.length;
}
public int getRowCount() {
return data.length;
}
public Object getValueAt(int row, int col) {
return data[row][col];
}
public String getColumnName(int column) {
return columnNames[column];
}
public Class<?> getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
public boolean isCellEditable(int row, int col) {
return col != 5;
}
public void setValueAt(Object aValue, int row, int column) {
data[row][column] = aValue;
}
};
table.setModel(dataModel);
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(dataModel);
table.setRowSorter(sorter);
JScrollPane scrollPane = new JScrollPane(table);
newContentPane.add(scrollPane);
frame.pack();
frame.setLocation(0, 0);
frame.setVisible(true);
}
use of javax.swing.table.TableModel in project azure-tools-for-java by Microsoft.
the class TableEntityForm method doOKAction.
@Override
protected void doOKAction() {
final TableModel model = propertiesTable.getModel();
final String partitionKey = model.getValueAt(0, 3).toString();
final String rowKey = model.getValueAt(1, 3).toString();
final Map<String, TableEntity.Property> properties = new LinkedHashMap<String, TableEntity.Property>();
for (int row = 2; row != model.getRowCount(); row++) {
TableEntity.PropertyType propertyType = (TableEntity.PropertyType) model.getValueAt(row, 2);
String name = model.getValueAt(row, 1).toString();
String value = model.getValueAt(row, 3).toString();
TableEntity.Property property = getProperty(value, propertyType);
properties.put(name, property);
}
ProgressManager.getInstance().run(new Task.Backgroundable(project, tableEntity == null ? "Creating entity" : "Updating entity", false) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
progressIndicator.setIndeterminate(true);
/*try {
if (tableEntity == null) {
tableEntity = StorageClientSDKManager.getManager().createTableEntity(storageAccount,
tableName,
partitionKey,
rowKey,
properties);
} else {
tableEntity.getProperties().clear();
tableEntity.getProperties().putAll(properties);
tableEntity = StorageClientSDKManager.getManager().updateTableEntity(storageAccount, tableEntity);
}
onFinish.run();
} catch (AzureCmdException e) {
String msg = "An error occurred while attempting to create entity." + "\n" + String.format(message("webappExpMsg"), e.getMessage());
PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e);
}*/
}
});
dispose();
}
use of javax.swing.table.TableModel in project otapij by FellowTraveler.
the class MarketTradesTableModel method setValue.
public void setValue(Map values, JTable table) {
clearValue();
System.out.println("values.size():" + values.size());
Set set = values.keySet();
Iterator iterator = set.iterator();
int i = 0;
data = new Object[values.size()][];
while (iterator.hasNext()) {
String key = (String) iterator.next();
String[] row = (String[]) values.get(key);
data[i] = row;
i++;
}
if (values.size() > 0) {
RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(this);
table.setRowSorter(sorter);
}
fireTableDataChanged();
}
use of javax.swing.table.TableModel in project otapij by FellowTraveler.
the class BitcoinReceivingAddrTableModel method setValue.
public void setValue(Map values, JTable receiveAddrTable) {
clearValue();
System.out.println("values.size():" + values.size());
Set set = values.keySet();
Iterator iterator = set.iterator();
int i = 0;
data = new Object[values.size()][];
while (iterator.hasNext()) {
String key = (String) iterator.next();
String[] row = (String[]) values.get(key);
data[i] = row;
i++;
}
RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(this);
receiveAddrTable.setRowSorter(sorter);
/*TableColumnModel tcm = receiveAddrTable.getColumnModel();
System.out.println("receivedTable.getColumn()"+tcm.getColumnCount());
if(tcm.getColumnCount()==6){
receiveAddrTable.removeColumn(tcm.getColumn(5));
}*/
fireTableDataChanged();
}
use of javax.swing.table.TableModel in project EnrichmentMapApp by BaderLab.
the class DataSetSelector method updateSelectionButtons.
private void updateSelectionButtons() {
final int rowCount = getTable().getRowCount();
TableModel model = getTable().getModel();
boolean hasUnchecked = false;
boolean hasChecked = false;
for (int i = 0; i < rowCount; i++) {
final boolean checked = (boolean) model.getValueAt(i, SELECTED_COL_IDX);
if (!hasUnchecked)
hasUnchecked = !checked;
if (!hasChecked)
hasChecked = checked;
if (hasUnchecked && hasChecked)
break;
}
getSelectAllButton().setEnabled(hasUnchecked);
getSelectNoneButton().setEnabled(hasChecked);
}
Aggregations