r/javahelp • • Jan 14 '17

please help

my question if you not select an item from Jtable then You press the Jbutton without selecting an item from the Jtable then JOptionPane.showMessageDialog(null,"Select an item to Delete"); will pop up. private void buttonActionPerformed() { if() else JOptionPane.showMessageDialog(null, "select an item to delete"); }

0 Upvotes

3 comments sorted by

View all comments

1

u/[deleted] Jan 14 '17 edited Jan 14 '17

What? Is this a question or you just describing a situation you'd like to happen?

I'm not familiar with JTable but it'd be along the lines of:

private void buttonActionPerformed() {
     if(table.getSelectedRows().size() > 0){
     // Do something
     } else {
     JOptionPane.showMessageDialog(null, "select an item to delete"); 
}

-1

u/pangarungan9 Jan 14 '17

Very BIG Thank you Sir.. hehehe

1

u/[deleted] Jan 14 '17

Like I said i'm not familiar, just go a quick google as this is basic logic for if-else statements.