本文整理匯總了Java中javax.swing.table.DefaultTableModel.getRowCount方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTableModel.getRowCount方法的具體用法?Java DefaultTableModel.getRowCount怎麽用?Java DefaultTableModel.getRowCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.table.DefaultTableModel
的用法示例。
在下文中一共展示了DefaultTableModel.getRowCount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fireChanged
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void fireChanged() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
ArrayList<String> patterns = new ArrayList<String>(model.getRowCount());
for (int i = 0; i < model.getRowCount(); i++) {
Object value = model.getValueAt(i, 0);
if (value == null) {
continue;
}
String pattern = value.toString();
//remove empty patterns
if (!pattern.trim().isEmpty() && !pattern.trim().equals(getDummyPattern())) {
patterns.add(pattern);
}
}
changed = !id2comments.isEmpty()
|| Settings.getDefault().isScanCommentsOnly() != checkScanCommentsOnly.isSelected()
|| Settings.getDefault().getPatterns().size() != patterns.size()
|| !Settings.getDefault().getPatterns().containsAll(patterns)
|| Settings.getDefault().getExtensionIdentifiers().size() != extensionIdentifiers.size()
|| !Settings.getDefault().getExtensionIdentifiers().containsAll(extensionIdentifiers)
|| Settings.getDefault().getMimeIdentifiers().size() != mimeIdentifiers.size()
|| !Settings.getDefault().getMimeIdentifiers().containsAll(mimeIdentifiers);
}
示例2: btnRemoveActionPerformed
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveActionPerformed
TableCellEditor editor = table.getCellEditor();
if( null != editor )
editor.cancelCellEditing();
boolean wasValid = isDataValid();
int selRow = table.getSelectedRow();
if( selRow < 0 )
return;
DefaultTableModel model = (DefaultTableModel)table.getModel();
model.removeRow( selRow );
if( selRow > model.getRowCount()-1 )
selRow--;
if( selRow >= 0 )
table.getSelectionModel().setSelectionInterval( selRow, selRow );
boolean wasChanged = changed;
fireChanged();
firePropertyChange( OptionsPanelController.PROP_CHANGED, new Boolean(wasChanged), Boolean.TRUE);
firePropertyChange( OptionsPanelController.PROP_VALID, new Boolean(wasValid), new Boolean(isDataValid()));
}
示例3: renameDomainInComponents
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
* Rename domain in components.
*
* @param oldDomainName the old domain name
* @param newDomainName the new domain name
*/
public void renameDomainInComponents(String oldDomainName, String newDomainName) {
DefaultTableModel dtmComponents = this.getTableModel4ComponentTypes();
int column = getColumnHeaderIndexComponents(COL_Domain);
// --- Get the component type definitions from table ----
JTable jtComponents = this.getJTable4ComponentTypes();
// --- Confirm, apply changes in table ------------------
TableCellEditor tceComponents = jtComponents.getCellEditor();
if (tceComponents!=null) {
tceComponents.stopCellEditing();
}
for(int row=0; row<dtmComponents.getRowCount(); row++){
String currValue = (String) dtmComponents.getValueAt(row, column);
if (currValue.equals(oldDomainName)) {
dtmComponents.setValueAt(newDomainName, row, column);
}
}
this.setTableCellEditor4DomainsInComponents(null);
}
示例4: convertTableModelToStringValue
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private String convertTableModelToStringValue(DefaultTableModel tableModel) {
StringBuilder stringBuilder = new StringBuilder();
int rowCount = tableModel.getRowCount();
for (int i = 0; i < rowCount; i++) {
String option = (String) tableModel.getValueAt(i, 0);
try {
Double min = Double.parseDouble((String) tableModel.getValueAt(i, 1));
Double max = Double.parseDouble((String) tableModel.getValueAt(i, 2));
String colorValue = (String) tableModel.getValueAt(i, 3);
stringBuilder.append(option + "=" + min + ".." + max + "->" + colorValue + ",");
} catch (Throwable skip) {
stringBuilder.append(option + "=" + 0 + ".." + 0 + "->" + "#FFFFFFFF" + ",");
}
}
return stringBuilder.toString();
}
示例5: isModified
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
* 是否已修改
*
* @return
*/
@Override
public boolean isModified() {
Variables variables = settingManager.getVariables();
DefaultTableModel tableModel = (DefaultTableModel) varTable.getModel();
if (variables.getParams().size() != tableModel.getRowCount()) {
return true;
}
Map<String, String> params = variables.getParams();
for (int i = 0; i < tableModel.getRowCount(); i++) {
String key = tableModel.getValueAt(i, 0).toString();
String value = tableModel.getValueAt(i, 1).toString();
if (!params.containsKey(key)) {
return true;
} else if (params.containsKey(key) && !params.get(key).equals(value)) {
return true;
}
}
if (!Objects.equals(ignoreText.getText().trim(), variables.getIgnoreFields())) {
return true;
}
return false;
}
示例6: filtersCheckAllButtonActionPerformed
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void filtersCheckAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filtersCheckAllButtonActionPerformed
DefaultTableModel model = (DefaultTableModel) filterClassesTable.getModel();
for (int i = 0; i < model.getRowCount(); i++) {
model.setValueAt(Boolean.TRUE, i, 0);
}
filterClassesTable.repaint();
}
示例7: saveCommonSettings
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void saveCommonSettings() {
if (driverPropTable.isEditing()) {
driverPropTable.getCellEditor().stopCellEditing();
}
DefaultTableModel model = (DefaultTableModel) driverPropTable.getModel();
settings.getDriverSettings().clear();
for (int i = 0; i < model.getRowCount(); i++) {
String prop = Objects.toString(model.getValueAt(i, 0), "").trim();
if (!prop.isEmpty()) {
String value = Objects.toString(model.getValueAt(i, 1), "");
settings.getDriverSettings().setProperty(prop, value);
}
}
}
示例8: moveDownVarButtonActionPerformed
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void moveDownVarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveDownVarButtonActionPerformed
int index = childrenVariablesTable.getSelectedRow();
if (index < 0) return ;
DefaultTableModel model = (DefaultTableModel) childrenVariablesTable.getModel();
if (index >= (model.getRowCount() - 1)) return ;
Object[] row = new Object[] { model.getValueAt(index, 0), model.getValueAt(index, 1) };
model.removeRow(index);
model.insertRow(index + 1, row);
childrenVariablesTable.getSelectionModel().setSelectionInterval(index + 1, index + 1);
}
示例9: writeTemplateData
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
* 保持模板數據
*
* @param msgName 消息名稱
* @throws IOException
*/
public void writeTemplateData(String msgName) throws IOException {
File dir = new File("data/template_data/");
File file = new File("data/template_data/" + msgName + ".csv");
if (!file.exists()) {
dir.mkdirs();
file.createNewFile();
}
CSVWriter writer = new CSVWriter(new FileWriter(file));
List<String[]> records = new ArrayList<String[]>();
// 如果table為空,則初始化
if (MainWindow.mainWindow.getTemplateMsgDataTable().getModel().getRowCount() == 0) {
Init.initTemplateDataTable();
}
// 逐行讀取
DefaultTableModel tableModel = (DefaultTableModel) MainWindow.mainWindow.getTemplateMsgDataTable()
.getModel();
int rowCount = tableModel.getRowCount();
String[] arryData;
for (int i = 0; i < rowCount; i++) {
arryData = new String[3];
arryData[0] = (String) tableModel.getValueAt(i, 0);
arryData[1] = (String) tableModel.getValueAt(i, 1);
arryData[2] = ((String) tableModel.getValueAt(i, 2)).trim();
records.add(arryData);
}
// 寫入文件
writer.writeAll(records);
writer.close();
}
示例10: fillTimeTable
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void fillTimeTable() {
Reference ref = (Reference)jList1.getSelectedValue();
Object fo = ref == null ? null : ref.get();
// clear the table
DefaultTableModel model = (DefaultTableModel) times.getModel();
while (model.getRowCount() > 0) {
model.removeRow(0);
}
key2RowNumber.clear();
if (fo == null) return;
Collection<String> keys = TimesCollectorPeer.getDefault().getKeysForFile(fo);
for (int i = 0; i < 10; i++) {
try {
synchronized(keys) {
for (String key : keys) {
changeRow(fo, key);
}
return;
}
} catch (ConcurrentModificationException ex) {
LOG.log(Level.INFO, "Retry " + i, ex);
}
}
}
示例11: limpiarTabla
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
public void limpiarTabla(DefaultTableModel modelo) //recibe el modelo de la tabla
{
int filas = modelo.getRowCount(); //para saber cuantas filas tiene la tabla hasta el momento
for(int i=0;i<filas;i++)//colocamos "<" porque sino borrara una fila inexistente
{
modelo.removeRow(0); //para que valla borrando borrando la PRIMERA linea(que en si es toda la tabla)
}
}
示例12: removeOptionButtonActionPerformed
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void removeOptionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeOptionButtonActionPerformed
DefaultTableModel model = (DefaultTableModel) processorOptionsTable.getModel();
int[] rows = processorOptionsTable.getSelectedRows();
for(int i = rows.length - 1 ; i >= 0 ; i--) {
model.removeRow(rows[i]);
}
if (model.getRowCount() > 0) {
// Select reasonable row
int selectedIndex = rows[rows.length - 1] - rows.length + 1;
if ( selectedIndex > model.getRowCount() - 1) {
selectedIndex = model.getRowCount() - 1;
}
processorOptionsTable.setRowSelectionInterval(selectedIndex, selectedIndex);
}
}
示例13: apply
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
/**
* 應用
*/
@Override
public void apply() {
Map<String, String> params = new HashMap<>();
DefaultTableModel tableModel = (DefaultTableModel) varTable.getModel();
for (int i = 0; i < tableModel.getRowCount(); i++) {
params.put(tableModel.getValueAt(i, 0).toString().trim(), tableModel.getValueAt(i, 1).toString().trim());
}
settingManager.getVariables().setParams(params);
settingManager.getVariables().setIgnoreFields(ignoreText.getText().trim());
}
示例14: checkTableExists
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private boolean checkTableExists(String number) {
DefaultTableModel model = (DefaultTableModel) table1.getModel();
List<String> numdata = new ArrayList<String>();
for (int count = 0; count < model.getRowCount(); count++) {
numdata.add(model.getValueAt(count, 0).toString());
}
return numdata.contains(number);
}
示例15: updateTable
import javax.swing.table.DefaultTableModel; //導入方法依賴的package包/類
private void updateTable(List list, final DefaultTableModel dftm) {
int num = dftm.getRowCount();
for (int i = 0; i < num; i++)
dftm.removeRow(0);
Iterator iterator = list.iterator();
TbKhinfo khInfo;
while (iterator.hasNext()) {
List info = (List) iterator.next();
Item item = new Item();
item.setId((String) info.get(0));
item.setName((String) info.get(1));
khInfo = Dao.getKhInfo(item);
Vector rowData = new Vector();
rowData.add(khInfo.getId().trim());
rowData.add(khInfo.getKhname().trim());
rowData.add(khInfo.getAddress().trim());
rowData.add(khInfo.getJian().trim());
rowData.add(khInfo.getBianma().trim());
rowData.add(khInfo.getTel().trim());
rowData.add(khInfo.getFax().trim());
rowData.add(khInfo.getLian().trim());
rowData.add(khInfo.getLtel().trim());
rowData.add(khInfo.getMail().trim());
rowData.add(khInfo.getXinhang().trim());
rowData.add(khInfo.getHao().trim());
dftm.addRow(rowData);
}
}