List of usage examples for javax.swing.table DefaultTableModel removeRow
public void removeRow(int row)
row
from the model. From source file:ca.uviccscu.lp.server.main.MainFrame.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed l.info("Remove game action activated"); //JOptionPane conf = new JOptionPane(); if (jTable1.getSelectedRow() >= 0) { int result = JOptionPane.showConfirmDialog(rootPane, "Are you sure you want to delete?", "Confirmation", 2, 3);//from w w w . j a v a 2 s.co m //JDialog dialog = conf.createDialog(jPanel1, "Are you sure u want to delete?"); //dialog.show(); //Object selectedValue = conf.getValue(); l.trace("Game delete dialog code: " + result); if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { l.trace("Game delete cancelled"); } else if (result == JOptionPane.OK_OPTION) { DefaultTableModel mdl = (DefaultTableModel) jTable1.getModel(); String name = (String) mdl.getValueAt(jTable1.getSelectedRow(), 0); if (name != null) { l.trace("Removing game: " + name); GamelistStorage.removeGame(name); SettingsManager.getStorage().removeGame(name); mdl.removeRow(jTable1.getSelectedRow()); l.debug("Game removed: " + name); } else { mdl.removeRow(jTable1.getSelectedRow()); l.trace("Empty row - just erasing in table"); } } } MainFrame.updateGameInterfaceFromStorage(); }
From source file:gdt.jgui.tool.JEntityEditor.java
private void deleteRows() { try {/*from w w w . j av a 2 s . c o m*/ JScrollPane scrollPane = (JScrollPane) tabbedPane.getSelectedComponent(); JTable table = (JTable) scrollPane.getViewport().getView(); DefaultTableModel tableModel = (DefaultTableModel) table.getModel(); ListSelectionModel listModel = table.getSelectionModel(); int rCnt = table.getRowCount(); ArrayList<Integer> srl = new ArrayList<Integer>(); for (int i = 0; i < rCnt; i++) if (listModel.isSelectedIndex(i)) { srl.add(new Integer(i)); } Integer[] sra = srl.toArray(new Integer[0]); ArrayList<Core> ol = new ArrayList<Core>(); Core row; boolean skip; for (int i = 0; i < rCnt; i++) { skip = false; for (int aSra : sra) { if (i == aSra) { skip = true; break; } } if (!skip) { row = new Core((String) tableModel.getValueAt(i, 0), (String) tableModel.getValueAt(i, 1), (String) tableModel.getValueAt(i, 2)); ol.add(row); } } Core[] ra = ol.toArray(new Core[0]); while (tableModel.getRowCount() > 0) tableModel.removeRow(0); for (Core aRa : ra) { tableModel.addRow(new String[] { aRa.type, aRa.name, aRa.value }); } } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:gdt.jgui.entity.fields.JFieldsEditor.java
private void deleteRows() { try {//ww w . j a va 2 s . c om JTable table = (JTable) scrollPane.getViewport().getView(); DefaultTableModel tableModel = (DefaultTableModel) table.getModel(); ListSelectionModel listModel = table.getSelectionModel(); int rCnt = table.getRowCount(); ArrayList<Integer> srl = new ArrayList<Integer>(); for (int i = 0; i < rCnt; i++) if (listModel.isSelectedIndex(i)) { srl.add(new Integer(i)); } Integer[] sra = srl.toArray(new Integer[0]); ArrayList<Core> ol = new ArrayList<Core>(); Core row; boolean skip; for (int i = 0; i < rCnt; i++) { skip = false; for (int aSra : sra) { if (i == aSra) { skip = true; break; } } if (!skip) { row = new Core(null, (String) tableModel.getValueAt(i, 0), (String) tableModel.getValueAt(i, 1)); ol.add(row); } } Core[] ra = ol.toArray(new Core[0]); while (tableModel.getRowCount() > 0) tableModel.removeRow(0); for (Core aRa : ra) { tableModel.addRow(new String[] { aRa.name, aRa.value }); } } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:Clavis.Windows.WShedule.java
public synchronized void refreshTable(int val) { DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel(); if (modelo.getRowCount() > 0) { int tam = modelo.getRowCount(); for (int h = 0; h < tam; h++) { modelo.removeRow(0); }//from ww w . j a v a 2 s.c o m } java.util.List<Keys.Request> requisicoes = new java.util.ArrayList<>(); if (DataBase.DataBase.testConnection(url)) { DataBase.DataBase db = new DataBase.DataBase(url); requisicoes = Clavis.RequestList .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim)); db.close(); } lista = new java.util.ArrayList<>(); andamento = 0; switch (val) { case 0: estado = lingua.translate("Todos"); for (Keys.Request req : requisicoes) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } break; case 1: estado = lingua.translate("terminado"); for (Keys.Request req : requisicoes) { if (req.isTerminated()) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; case 2: estado = lingua.translate("no realizado"); for (Keys.Request req : requisicoes) { if ((!req.isActive()) && ((req.getEndDate().isBigger(new TimeDate.Date()) > 0) || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0) && (req.getTimeEnd().compareTime(new TimeDate.Time()) > 0)))) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; case 3: estado = lingua.translate("por realizar"); for (Keys.Request req : requisicoes) { if ((!req.isActive()) && (!req.isTerminated()) && ((req.getEndDate().isBigger(new TimeDate.Date()) < 0) || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0) && (req.getTimeEnd().compareTime(new TimeDate.Time()) < 0)))) { String[] multipla = req.getActivity().split(":::"); String saux; if (multipla.length > 1) { saux = multipla[0]; Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); } else { saux = req.getActivity(); } if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), saux, req.getSubject().getName() }; modelo.addRow(ob); } else { Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), saux }; modelo.addRow(ob); } lista.add(req); andamento++; } } break; } valores = new String[lista.size()][4]; for (int i = 0; i < lista.size(); i++) { String[] multipla = lista.get(i).getActivity().split(":::"); String saux = multipla[0]; if (saux.equals("")) { saux = lingua.translate("Sem descrio"); } if (mat.getMaterialTypeID() == 1) { valores[i][0] = lista.get(i).getPerson().getName(); valores[i][1] = lista.get(i).getTimeBegin().toString(0) + " - " + lista.get(i).getTimeEnd().toString(0); valores[i][2] = lista.get(i).getBeginDate().toString(); valores[i][3] = saux + " - " + lista.get(i).getSubject().getName(); } else { valores[i][0] = lista.get(i).getPerson().getName(); valores[i][1] = lista.get(i).getBeginDate().toString(); valores[i][2] = lista.get(i).getEndDate().toString(); valores[i][3] = saux; } } }
From source file:com.mirth.connect.connectors.file.AdvancedSftpSettingsDialog.java
private void initComponents() { authenticationLabel = new JLabel("Authentication:"); usePasswordRadio = new JRadioButton("Password"); usePasswordRadio.setFocusable(false); usePasswordRadio.setBackground(new Color(255, 255, 255)); usePasswordRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); usePasswordRadio.setToolTipText("Select this option to use a password to gain access to the server."); usePasswordRadio.addActionListener(new ActionListener() { @Override//from w ww. ja v a 2 s . c o m public void actionPerformed(ActionEvent e) { authenticationRadioButtonActionPerformed(); } }); usePrivateKeyRadio = new JRadioButton("Public Key"); usePrivateKeyRadio.setSelected(true); usePrivateKeyRadio.setFocusable(false); usePrivateKeyRadio.setBackground(UIConstants.BACKGROUND_COLOR); usePrivateKeyRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); usePrivateKeyRadio .setToolTipText("Select this option to use a public/private keypair to gain access to the server."); usePrivateKeyRadio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { authenticationRadioButtonActionPerformed(); } }); useBothRadio = new JRadioButton("Both"); useBothRadio.setSelected(true); useBothRadio.setFocusable(false); useBothRadio.setBackground(UIConstants.BACKGROUND_COLOR); useBothRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useBothRadio.setToolTipText( "Select this option to use both a password and a public/private keypair to gain access to the server."); useBothRadio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { authenticationRadioButtonActionPerformed(); } }); privateKeyButtonGroup = new ButtonGroup(); privateKeyButtonGroup.add(usePasswordRadio); privateKeyButtonGroup.add(usePrivateKeyRadio); privateKeyButtonGroup.add(useBothRadio); keyLocationLabel = new JLabel("Public/Private Key File:"); keyLocationField = new JTextField(); keyLocationField.setToolTipText( "The absolute file path of the public/private keypair used to gain access to the remote server."); passphraseLabel = new JLabel("Passphrase:"); passphraseField = new JPasswordField(); passphraseField.setToolTipText("The passphrase associated with the public/private keypair."); useKnownHostsLabel = new JLabel("Host Key Checking:"); useKnownHostsYesRadio = new JRadioButton("Yes"); useKnownHostsYesRadio.setFocusable(false); useKnownHostsYesRadio.setBackground(UIConstants.BACKGROUND_COLOR); useKnownHostsYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useKnownHostsYesRadio.setToolTipText( "<html>Select this option to validate the server's host key within the provided<br>Known Hosts file. Known Hosts file is required.</html>"); useKnownHostsAskRadio = new JRadioButton("Ask"); useKnownHostsAskRadio.setFocusable(false); useKnownHostsAskRadio.setBackground(UIConstants.BACKGROUND_COLOR); useKnownHostsAskRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useKnownHostsAskRadio.setToolTipText( "<html>Select this option to ask the user to add the server's host key to the provided<br>Known Hosts file. Known Hosts file is optional.</html>"); useKnownHostsNoRadio = new JRadioButton("No"); useKnownHostsNoRadio.setSelected(true); useKnownHostsNoRadio.setFocusable(false); useKnownHostsNoRadio.setBackground(UIConstants.BACKGROUND_COLOR); useKnownHostsNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); useKnownHostsNoRadio.setToolTipText( "<html>Select this option to always add the server's host key to the provided<br>Known Hosts file. Known Hosts file is optional.</html>"); knownHostsButtonGroup = new ButtonGroup(); knownHostsButtonGroup.add(useKnownHostsYesRadio); knownHostsButtonGroup.add(useKnownHostsAskRadio); knownHostsButtonGroup.add(useKnownHostsNoRadio); knownHostsLocationLabel = new JLabel("Known Hosts File:"); knownHostsField = new JTextField(); knownHostsField .setToolTipText("The path to the local Known Hosts file used to authenticate the remote server."); configurationsLabel = new JLabel("Configuration Options:"); configurationsTable = new MirthTable(); Object[][] tableData = new Object[0][1]; configurationsTable.setModel(new RefreshTableModel(tableData, new String[] { "Name", "Value" })); configurationsTable.setOpaque(true); configurationsTable.getColumnModel() .getColumn(configurationsTable.getColumnModel().getColumnIndex(NAME_COLUMN_NAME)) .setCellEditor(new ConfigTableCellEditor(true)); configurationsTable.getColumnModel() .getColumn(configurationsTable.getColumnModel().getColumnIndex(VALUE_COLUMN_NAME)) .setCellEditor(new ConfigTableCellEditor(false)); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); configurationsTable.setHighlighters(highlighter); } configurationsScrollPane = new JScrollPane(); configurationsScrollPane.getViewport().add(configurationsTable); newButton = new JButton("New"); newButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultTableModel model = (DefaultTableModel) configurationsTable.getModel(); Vector<String> row = new Vector<String>(); String header = "Property"; for (int i = 1; i <= configurationsTable.getRowCount() + 1; i++) { boolean exists = false; for (int index = 0; index < configurationsTable.getRowCount(); index++) { if (((String) configurationsTable.getValueAt(index, 0)).equalsIgnoreCase(header + i)) { exists = true; } } if (!exists) { row.add(header + i); break; } } model.addRow(row); int rowSelectionNumber = configurationsTable.getRowCount() - 1; configurationsTable.setRowSelectionInterval(rowSelectionNumber, rowSelectionNumber); Boolean enabled = deleteButton.isEnabled(); if (!enabled) { deleteButton.setEnabled(true); } } }); deleteButton = new JButton("Delete"); deleteButton.setEnabled(false); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int rowSelectionNumber = configurationsTable.getSelectedRow(); if (rowSelectionNumber > -1) { DefaultTableModel model = (DefaultTableModel) configurationsTable.getModel(); model.removeRow(rowSelectionNumber); rowSelectionNumber--; if (rowSelectionNumber > -1) { configurationsTable.setRowSelectionInterval(rowSelectionNumber, rowSelectionNumber); } if (configurationsTable.getRowCount() == 0) { deleteButton.setEnabled(false); } } } }); okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okCancelButtonActionPerformed(); } }); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { dispose(); } }); authenticationRadioButtonActionPerformed(); }
From source file:grupob.TipoProceso.java
private void tblInstitucionalMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblInstitucionalMouseClicked // TODO add your handling code here: DefaultTableModel modelo = (DefaultTableModel) tblInstitucional.getModel(); int row = tblInstitucional.rowAtPoint(evt.getPoint()); int col = tblInstitucional.columnAtPoint(evt.getPoint()); if (col == 3) { int dialogButton = JOptionPane.YES_NO_OPTION; int n = JOptionPane.showConfirmDialog(null, "Estas Seguro que deseas eliminar?", "Advertencia", dialogButton);/*from ww w .j a va2 s .com*/ if (n == JOptionPane.YES_OPTION) { String nombre = tblInstitucional.getValueAt(row, 0).toString(); //Buscar el id en la lista for (int i = 0; i < listaInstituciones.size(); i++) { if (listaInstituciones.get(i).getNombre().equals(nombre)) { Manager.deleteInstitucion(listaInstituciones.get(i).getId()); listaInstituciones.remove(i);//Ver si es correcto esto break; } } modelo.removeRow(tblInstitucional.getSelectedRow()); } } }
From source file:com.peterbochs.instrument.InstrumentPanel.java
private void updateHotestTable(long address, long blockSize) { DefaultTableModel jHotestAddressTableModel = (DefaultTableModel) jHotestAddressTable.getModel(); while (jHotestAddressTableModel.getRowCount() > 0) { jHotestAddressTableModel.removeRow(0); }/*from www. j av a2s . co m*/ HashMap<String, Integer> map = Data.getHotestAddressCount(address, blockSize); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); jHotestAddressTableModel .addRow(new String[] { entry.getKey().toString(), entry.getValue().toString() }); } }
From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java
public void doExport() { //build attack table DefaultTableModel model = (DefaultTableModel) jAttackExportTable.getModel(); int rows = model.getRowCount(); for (int i = 0; i < rows; i++) { model.removeRow(0); }// w w w . ja va2 s. co m Iterator<String> plans = AttackManager.getSingleton().getGroupIterator(); while (plans.hasNext()) { String next = plans.next(); model.addRow(new Object[] { next, Boolean.FALSE }); } //build marker set table String[] sets = MarkerManager.getSingleton().getGroups(); model = (DefaultTableModel) jMarkerSetExportTable.getModel(); rows = model.getRowCount(); for (int i = 0; i < rows; i++) { model.removeRow(0); } for (String set : sets) { model.addRow(new Object[] { set, Boolean.FALSE }); } //build report set table String[] reportSets = ReportManager.getSingleton().getGroups(); model = (DefaultTableModel) jReportSetExportTable.getModel(); rows = model.getRowCount(); for (int i = 0; i < rows; i++) { model.removeRow(0); } for (String set : reportSets) { model.addRow(new Object[] { set, Boolean.FALSE }); } //build troop table String[] troopSets = TroopsManager.getSingleton().getGroups(); model = (DefaultTableModel) jTroopSetExportTable.getModel(); rows = model.getRowCount(); for (int i = 0; i < rows; i++) { model.removeRow(0); } for (String set : troopSets) { model.addRow(new Object[] { set, Boolean.FALSE }); } //build note table String[] noteSets = NoteManager.getSingleton().getGroups(); model = (DefaultTableModel) jNoteSetExportTable.getModel(); rows = model.getRowCount(); for (int i = 0; i < rows; i++) { model.removeRow(0); } for (String set : noteSets) { model.addRow(new Object[] { set, Boolean.FALSE }); } jExportDialog.setAlwaysOnTop(true); jExportDialog.setVisible(true); }
From source file:Sales.TabbedPaneWin.java
private void removeSelectedBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeSelectedBtnActionPerformed //checking selected row is avalible 0,1,23, if (clientCartTable.getSelectedRow() != -1) { double totalAmount = Double .parseDouble(clientCartTable.getValueAt(clientCartTable.getSelectedRow(), 4).toString()); totalAmount = Double.valueOf(totAmountLbl1.getText()) - totalAmount; totAmountLbl1.setText(Double.toString(totalAmount)); DefaultTableModel model = (DefaultTableModel) clientCartTable.getModel(); model.removeRow(clientCartTable.getSelectedRow()); //visibleing Jbuttons if (clientCartTable.getRowCount() == 0) {//0 cuz its after remonivug row else 1 removeSelectedBtn.setEnabled(false); ClearCartBtn.setEnabled(false); } else {//from w w w. j av a2 s .co m removeSelectedBtn.setEnabled(true); ClearCartBtn.setEnabled(true); } } else { JOptionPane.showMessageDialog(null, "Error: Select a row From Client Cart Table to Remove.."); } }
From source file:interfaces.InterfazPrincipal.java
private void tablaMostrarComprasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaMostrarComprasMouseClicked // TODO add your handling code here: int fila = tablaMostrarCompras.getSelectedRow(); int identificacion = (int) tablaMostrarCompras.getValueAt(fila, 0); Object opciones[] = { "Editar", "Eliminar" }; ControladorCompraProveedor controladorCompraProveedor = new ControladorCompraProveedor(); ControladorFlujoCompras controladorFlujoCompras = new ControladorFlujoCompras(); int opcion = JOptionPane.showOptionDialog(this, "Que operacin desea realizar con la compra nmero " + identificacion + "?", "Mensaje del sistema", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, opciones, null);//from ww w . j av a 2 s . c o m switch (opcion) { case 0: String valor = JOptionPane.showInputDialog("Desea cambiar el monto de la compra\nEl monto actual es: " + tablaMostrarCompras.getValueAt(fila, 3)); Double.parseDouble(valor); controladorCompraProveedor.editarCompraProveedor(String.valueOf(identificacion), valor); //Editar flujos //Registrar nueva deuda controladorFlujoCompras.registrarFlujoDeuda(String.valueOf(identificacion), valor); controladorFlujoCompras.registrarFlujoAbono(String.valueOf(identificacion), String.valueOf(tablaMostrarCompras.getValueAt(fila, 3))); tablaMostrarCompras.setValueAt(valor, fila, 3); try { } catch (Exception e) { JOptionPane.showMessageDialog(this, "El monto debe ser numrico", "Error", JOptionPane.ERROR_MESSAGE); } break; case 1: int confirmacion = JOptionPane.showConfirmDialog(this, "Quieres eliminar la compra nmero " + identificacion + "?"); if (confirmacion == JOptionPane.YES_OPTION) { controladorCompraProveedor .eliminarCompraProveedor(" where ID_Compra_Proveedor = " + identificacion); DefaultTableModel modeloTabla = (DefaultTableModel) tablaMostrarCompras.getModel(); modeloTabla.removeRow(fila); tablaMostrarCompras.setModel(modeloTabla); //Eliminar flujo controladorFlujoCompras.borrarFlujosDeUnaCompraPorIDDeCompra(String.valueOf(identificacion)); } break; default: break; } }