Delete Value from Table with JPopupMenu | Java Swing
________________________________________________
DefaultTableModel model1 = (DefaultTableModel) table.getModel(); try{ int row = table.getSelectedRow(); int response = JOptionPane.showConfirmDialog(null, "Do you want delete?", "DELETE!", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if(response == JOptionPane.YES_OPTION){ model1.removeRow(row); JOptionPane.showMessageDialog(null, "Deleted!"); } }catch(Exception e){ JOptionPane.showMessageDialog(null, "Error!"); }
_____________________________________________
Dark Hers
YouTube
https://instagram.com/darkhers
https://www.facebook.com/darkhers
TikTok
https://www.tiktok.com/@darkhers
https://www.pinterest.co.uk/darkhers
Comments
Post a Comment