Java Code Examples for javax.swing.table.DefaultTableModel#getRowCount()
The following examples show how to use
javax.swing.table.DefaultTableModel#getRowCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FBGraphExtractorPanel.java From wandora with GNU General Public License v3.0 | 6 votes |
private void setup() { String token = tokenField.getText(); AbstractFBGraphExtractor.setAccessToken(token); AbstractFBGraphExtractor.setupClient(); List<String> scopes = AbstractFBGraphExtractor.getScopes(); DefaultTableModel m = (DefaultTableModel)permTable.getModel(); for (int i = 0; i < m.getRowCount(); i++) { String scope = (String)m.getValueAt(i, 0); if(scopes.contains(scope)){ m.setValueAt("granted", i, 1); m.setValueAt(true, i , 2); } else { m.setValueAt("not granted", i, 1); m.setValueAt(false, i , 2); } } }
Example 2
Source File: WxMaSubscribeMsgMaker.java From WePush with MIT License | 6 votes |
/** * 准备(界面字段等) */ @Override public void prepare() { templateId = MaSubscribeMsgForm.getInstance().getMsgTemplateIdTextField().getText().trim(); templateUrl = MaSubscribeMsgForm.getInstance().getMsgTemplateUrlTextField().getText().trim(); if (MaSubscribeMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { MaSubscribeMsgForm.initTemplateDataTable(); } DefaultTableModel tableModel = (DefaultTableModel) MaSubscribeMsgForm.getInstance().getTemplateMsgDataTable().getModel(); int rowCount = tableModel.getRowCount(); TemplateData templateData; templateDataList = Lists.newArrayList(); for (int i = 0; i < rowCount; i++) { String name = ((String) tableModel.getValueAt(i, 0)).trim(); String value = ((String) tableModel.getValueAt(i, 1)).trim(); String color = ((String) tableModel.getValueAt(i, 2)).trim(); templateData = new TemplateData(); templateData.setName(name); templateData.setValue(value); templateData.setColor(color); templateDataList.add(templateData); } }
Example 3
Source File: ArrangementGroupingRulesControl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public List<ArrangementGroupingRule> getRules() { List<ArrangementGroupingRule> result = new ArrayList<ArrangementGroupingRule>(); DefaultTableModel model = getModel(); for (int i = 0, max = model.getRowCount(); i < max; i++) { ArrangementGroupingComponent component = (ArrangementGroupingComponent)model.getValueAt(i, 0); if (!component.isSelected()) { continue; } ArrangementSettingsToken orderType = component.getOrderType(); if (orderType == null) { result.add(new ArrangementGroupingRule(component.getGroupingType())); } else { result.add(new ArrangementGroupingRule(component.getGroupingType(), orderType)); } } return result; }
Example 4
Source File: VariableUI.java From CodeGen with MIT License | 6 votes |
/** * 是否已修改 */ @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; }
Example 5
Source File: XMLExportIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testExport() throws Exception { final MasterReport report = new MasterReport(); final ItemBand itemBand = report.getItemBand(); final TextFieldElementFactory cfef = new TextFieldElementFactory(); cfef.setFieldname( "field" ); cfef.setMinimumWidth( new Float( 500 ) ); cfef.setMinimumHeight( new Float( 200 ) ); itemBand.addElement( cfef.createElement() ); final DefaultTableModel tableModel = new DefaultTableModel( new String[] { "field" }, 2000 ); for ( int row = 0; row < tableModel.getRowCount(); row++ ) { tableModel.setValueAt( "Value row = " + row, row, 0 ); } report.setDataFactory( new TableDataFactory( "default", tableModel ) ); DebugReportRunner.createDataXML( report ); }
Example 6
Source File: TxYunMsgMaker.java From WePush with MIT License | 6 votes |
/** * 准备(界面字段等) */ @Override public void prepare() { templateId = Integer.parseInt(TxYunMsgForm.getInstance().getMsgTemplateIdTextField().getText()); if (TxYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { TxYunMsgForm.initTemplateDataTable(); } DefaultTableModel tableModel = (DefaultTableModel) TxYunMsgForm.getInstance().getTemplateMsgDataTable().getModel(); int rowCount = tableModel.getRowCount(); paramList = Lists.newArrayList(); for (int i = 0; i < rowCount; i++) { String value = ((String) tableModel.getValueAt(i, 1)); paramList.add(value); } }
Example 7
Source File: CImportBibTex.java From Zettelkasten with GNU General Public License v3.0 | 5 votes |
private void filterList(boolean regEx) { // when we filter the table and want to restore it, we don't need to run the // time-consuming task that creates the author-list and related author-frequencies. // instead, we simply copy the values from the linkedlist to the table-model, which is // much faster. but therefore we have to apply all changes to the filtered-table // (like adding/changing values in a filtered list) to the linked list as well. // get text from the textfield containing the filter string // convert to lowercase, we don't want case-sensitive search String text = jTextFieldFilterTable.getText().toLowerCase(); // when we have no text, do nothing if (text.isEmpty()) { return; } // get table model DefaultTableModel dtm = (DefaultTableModel) jTableBibEntries.getModel(); // if we haven't already stored the current complete table data, do this now if (null == linkedtablelist) { // create new instance of list linkedtablelist = new LinkedList<>(); // go through all table-data for (int cnt = 0; cnt < dtm.getRowCount(); cnt++) { // init the object-variable Object[] o = new Object[2]; // fill object with values o[0] = dtm.getValueAt(jTableBibEntries.convertRowIndexToModel(cnt), 0); o[1] = dtm.getValueAt(jTableBibEntries.convertRowIndexToModel(cnt), 1); // add object to linked list linkedtablelist.add(o); } } TableUtils.filterTable(jTableBibEntries, dtm, text, new int[]{1}, regEx); // reset textfield jTextFieldFilterTable.setText(""); jTextFieldFilterTable.requestFocusInWindow(); // enable textfield only if we have more than 1 element in the jtable jTextFieldFilterTable.setEnabled(jTableBibEntries.getRowCount() > 0); // enable refresh button jButtonRefresh.setEnabled(true); }
Example 8
Source File: SecurityRolesEditorPanel.java From netbeans with Apache License 2.0 | 5 votes |
public String[] getSelectedRoles() { DefaultTableModel model = (DefaultTableModel) selectedRolesTable.getModel(); int rowCount = model.getRowCount(); String[] selectedRoles = new String[rowCount]; for (int i = 0; i < rowCount; i++) { selectedRoles[i] = (String) model.getValueAt(i, 0); } return selectedRoles; }
Example 9
Source File: CustomizerCompile.java From netbeans with Apache License 2.0 | 5 votes |
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); } }
Example 10
Source File: TransportOrderView.java From openAGV with Apache License 2.0 | 5 votes |
/** * Wird aufgerufen, wenn sich die Auswahl in der Tabelle der Fahraufträge * geändert hat. */ private void driveOrdersTableSelectionChanged() { DriveOrder driveOrder = fTransportOrder.getAllDriveOrders().get(driveOrdersTable.getSelectedRow()); DefaultTableModel routeTableModel = (DefaultTableModel) routeTable.getModel(); DefaultTableModel driveOrderPropsTableModel = (DefaultTableModel) driveOrderPropertiesTable.getModel(); while (routeTableModel.getRowCount() > 0) { routeTableModel.removeRow(0); } while (driveOrderPropsTableModel.getRowCount() > 0) { driveOrderPropsTableModel.removeRow(0); } for (Entry<String, String> entry : driveOrder.getDestination().getProperties().entrySet()) { driveOrderPropsTableModel.addRow(new String[] {entry.getKey(), entry.getValue()}); } if (driveOrder.getRoute() == null) { return; } costsTextField.setText(Long.toString(driveOrder.getRoute().getCosts())); for (Step step : driveOrder.getRoute().getSteps()) { routeTableModel.addRow(new String[] { step.getPath() == null ? "" : step.getPath().getName(), step.getDestinationPoint().getName() }); } }
Example 11
Source File: FBGraphExtractorPanel.java From wandora with GNU General Public License v3.0 | 5 votes |
private void toggleAllPermissions(boolean b) { DefaultTableModel m = (DefaultTableModel)permTable.getModel(); for (int i = 0; i < m.getRowCount(); i++) { m.setValueAt(b, i, 2); } }
Example 12
Source File: VariableFormatterEditPanel.java From netbeans with Apache License 2.0 | 5 votes |
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); }
Example 13
Source File: UpYunMsgForm.java From WePush with MIT License | 4 votes |
@Override public void save(String msgName) { int msgId = 0; boolean existSameMsg = false; List<TMsgSms> tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.UP_YUN_CODE, msgName); if (tMsgSmsList.size() > 0) { existSameMsg = true; msgId = tMsgSmsList.get(0).getId(); } int isCover = JOptionPane.NO_OPTION; if (existSameMsg) { // 如果存在,是否覆盖 isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的历史消息,\n是否覆盖?", "确认", JOptionPane.YES_NO_OPTION); } if (!existSameMsg || isCover == JOptionPane.YES_OPTION) { String templateId = getInstance().getMsgTemplateIdTextField().getText(); String now = SqliteUtil.nowDateForSqlite(); TMsgSms tMsgSms = new TMsgSms(); tMsgSms.setMsgType(MessageTypeEnum.UP_YUN_CODE); tMsgSms.setMsgName(msgName); tMsgSms.setTemplateId(templateId); tMsgSms.setCreateTime(now); tMsgSms.setModifiedTime(now); if (existSameMsg) { msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms); } else { msgSmsMapper.insertSelective(tMsgSms); msgId = tMsgSms.getId(); } // 保存模板数据 // 如果是覆盖保存,则先清空之前的模板数据 if (existSameMsg) { templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.UP_YUN_CODE, msgId); } // 如果table为空,则初始化 if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { initTemplateDataTable(); } // 逐行读取 DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() .getModel(); int rowCount = tableModel.getRowCount(); for (int i = 0; i < rowCount; i++) { String name = (String) tableModel.getValueAt(i, 0); String value = (String) tableModel.getValueAt(i, 1); TTemplateData tTemplateData = new TTemplateData(); tTemplateData.setMsgType(MessageTypeEnum.UP_YUN_CODE); tTemplateData.setMsgId(msgId); tTemplateData.setName(name); tTemplateData.setValue(value); tTemplateData.setCreateTime(now); tTemplateData.setModifiedTime(now); templateDataMapper.insert(tTemplateData); } JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功", JOptionPane.INFORMATION_MESSAGE); } }
Example 14
Source File: BdYunMsgForm.java From WePush with MIT License | 4 votes |
@Override public void save(String msgName) { int msgId = 0; boolean existSameMsg = false; List<TMsgSms> tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.BD_YUN_CODE, msgName); if (tMsgSmsList.size() > 0) { existSameMsg = true; msgId = tMsgSmsList.get(0).getId(); } int isCover = JOptionPane.NO_OPTION; if (existSameMsg) { // 如果存在,是否覆盖 isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的历史消息,\n是否覆盖?", "确认", JOptionPane.YES_NO_OPTION); } if (!existSameMsg || isCover == JOptionPane.YES_OPTION) { String templateId = getInstance().getMsgTemplateIdTextField().getText(); String now = SqliteUtil.nowDateForSqlite(); TMsgSms tMsgSms = new TMsgSms(); tMsgSms.setMsgType(MessageTypeEnum.BD_YUN_CODE); tMsgSms.setMsgName(msgName); tMsgSms.setTemplateId(templateId); tMsgSms.setCreateTime(now); tMsgSms.setModifiedTime(now); if (existSameMsg) { msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms); } else { msgSmsMapper.insertSelective(tMsgSms); msgId = tMsgSms.getId(); } // 保存模板数据 // 如果是覆盖保存,则先清空之前的模板数据 if (existSameMsg) { templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.BD_YUN_CODE, msgId); } // 如果table为空,则初始化 if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { initTemplateDataTable(); } // 逐行读取 DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() .getModel(); int rowCount = tableModel.getRowCount(); for (int i = 0; i < rowCount; i++) { String name = (String) tableModel.getValueAt(i, 0); String value = (String) tableModel.getValueAt(i, 1); TTemplateData tTemplateData = new TTemplateData(); tTemplateData.setMsgType(MessageTypeEnum.BD_YUN_CODE); tTemplateData.setMsgId(msgId); tTemplateData.setName(name); tTemplateData.setValue(value); tTemplateData.setCreateTime(now); tTemplateData.setModifiedTime(now); templateDataMapper.insert(tTemplateData); } JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功", JOptionPane.INFORMATION_MESSAGE); } }
Example 15
Source File: SettingsDialog.java From megabasterd with GNU General Public License v3.0 | 4 votes |
private void remove_elc_account_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove_elc_account_buttonActionPerformed DefaultTableModel model = (DefaultTableModel) elc_accounts_table.getModel(); int selected = elc_accounts_table.getSelectedRow(); while (selected >= 0) { String host = (String) model.getValueAt(elc_accounts_table.convertRowIndexToModel(selected), 0); _deleted_elc_accounts.add(host); model.removeRow(elc_accounts_table.convertRowIndexToModel(selected)); selected = elc_accounts_table.getSelectedRow(); } elc_accounts_table.clearSelection(); if (model.getRowCount() == 0) { remove_elc_account_button.setEnabled(false); } }
Example 16
Source File: XTable.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void emptyTable() { DefaultTableModel model = (DefaultTableModel)getModel(); while (model.getRowCount()>0) model.removeRow(0); }
Example 17
Source File: XTable.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public void emptyTable() { DefaultTableModel model = (DefaultTableModel)getModel(); while (model.getRowCount()>0) model.removeRow(0); }
Example 18
Source File: TxYunMsgForm.java From WePush with MIT License | 4 votes |
@Override public void save(String msgName) { int msgId = 0; boolean existSameMsg = false; List<TMsgSms> tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.TX_YUN_CODE, msgName); if (tMsgSmsList.size() > 0) { existSameMsg = true; msgId = tMsgSmsList.get(0).getId(); } int isCover = JOptionPane.NO_OPTION; if (existSameMsg) { // 如果存在,是否覆盖 isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的历史消息,\n是否覆盖?", "确认", JOptionPane.YES_NO_OPTION); } if (!existSameMsg || isCover == JOptionPane.YES_OPTION) { String templateId = getInstance().getMsgTemplateIdTextField().getText(); String now = SqliteUtil.nowDateForSqlite(); TMsgSms tMsgSms = new TMsgSms(); tMsgSms.setMsgType(MessageTypeEnum.TX_YUN_CODE); tMsgSms.setMsgName(msgName); tMsgSms.setTemplateId(templateId); tMsgSms.setCreateTime(now); tMsgSms.setModifiedTime(now); if (existSameMsg) { msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms); } else { msgSmsMapper.insertSelective(tMsgSms); msgId = tMsgSms.getId(); } // 保存模板数据 // 如果是覆盖保存,则先清空之前的模板数据 if (existSameMsg) { templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.TX_YUN_CODE, msgId); } // 如果table为空,则初始化 if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { initTemplateDataTable(); } // 逐行读取 DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() .getModel(); int rowCount = tableModel.getRowCount(); for (int i = 0; i < rowCount; i++) { String name = (String) tableModel.getValueAt(i, 0); String value = (String) tableModel.getValueAt(i, 1); TTemplateData tTemplateData = new TTemplateData(); tTemplateData.setMsgType(MessageTypeEnum.TX_YUN_CODE); tTemplateData.setMsgId(msgId); tTemplateData.setName(name); tTemplateData.setValue(value); tTemplateData.setCreateTime(now); tTemplateData.setModifiedTime(now); templateDataMapper.insert(tTemplateData); } JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功", JOptionPane.INFORMATION_MESSAGE); } }
Example 19
Source File: XTable.java From hottub with GNU General Public License v2.0 | 4 votes |
public void emptyTable() { DefaultTableModel model = (DefaultTableModel)getModel(); while (model.getRowCount()>0) model.removeRow(0); }
Example 20
Source File: HwYunMsgForm.java From WePush with MIT License | 4 votes |
@Override public void save(String msgName) { int msgId = 0; boolean existSameMsg = false; List<TMsgSms> tMsgSmsList = msgSmsMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.HW_YUN_CODE, msgName); if (tMsgSmsList.size() > 0) { existSameMsg = true; msgId = tMsgSmsList.get(0).getId(); } int isCover = JOptionPane.NO_OPTION; if (existSameMsg) { // 如果存在,是否覆盖 isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的历史消息,\n是否覆盖?", "确认", JOptionPane.YES_NO_OPTION); } if (!existSameMsg || isCover == JOptionPane.YES_OPTION) { String templateId = getInstance().getMsgTemplateIdTextField().getText(); String now = SqliteUtil.nowDateForSqlite(); TMsgSms tMsgSms = new TMsgSms(); tMsgSms.setMsgType(MessageTypeEnum.HW_YUN_CODE); tMsgSms.setMsgName(msgName); tMsgSms.setTemplateId(templateId); tMsgSms.setCreateTime(now); tMsgSms.setModifiedTime(now); if (existSameMsg) { msgSmsMapper.updateByMsgTypeAndMsgName(tMsgSms); } else { msgSmsMapper.insertSelective(tMsgSms); msgId = tMsgSms.getId(); } // 保存模板数据 // 如果是覆盖保存,则先清空之前的模板数据 if (existSameMsg) { templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.HW_YUN_CODE, msgId); } // 如果table为空,则初始化 if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { initTemplateDataTable(); } // 逐行读取 DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() .getModel(); int rowCount = tableModel.getRowCount(); for (int i = 0; i < rowCount; i++) { String name = (String) tableModel.getValueAt(i, 0); String value = (String) tableModel.getValueAt(i, 1); TTemplateData tTemplateData = new TTemplateData(); tTemplateData.setMsgType(MessageTypeEnum.HW_YUN_CODE); tTemplateData.setMsgId(msgId); tTemplateData.setName(name); tTemplateData.setValue(value); tTemplateData.setCreateTime(now); tTemplateData.setModifiedTime(now); templateDataMapper.insert(tTemplateData); } JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功", JOptionPane.INFORMATION_MESSAGE); } }