Good morning, I hope we can learn from the topic that I am trying to solve, but that I have stuck and I can not solve it.
Hopefully we can all learn in this beautiful forum.
I have the following line of code in which I insert the data of the selected row in the text field.
the following is in a jpopupmenu,
int fila = tbfacturas.getSelectedRow();
if (fila >= 0) {
txtodc.setText(tbfacturas.getValueAt(fila, 0).toString());
txtfactura.setText(tbfacturas.getValueAt(fila, 1).toString());
} else {
JOptionPane.showMessageDialog(null, "no seleciono fila");
}
I want you to make multiple selections and instead of loading the data into a text field, invoking the method to insert them into the database, only I understand that
A JTable by default works in MULTIPLE_INTERVAL_SELECTION mode if you do not change it. The following modes exist:
ListSelectionModel.SINGLE_SELECTION - You can select only one index ListSelectionModel.SINGLE_INTERVAL_SELECTION - you can select consecutive indexes ListSelectionModel.MULTIPLE_INTERVAL_SELECTION - you can select without restriction
What happens is that I use table.getSelectedRow () that only returns the number of the last selected row. what I'm looking for is:
int[] seleccionados = tabla.getSelectedRows();
You can help me-support me with this method, how to invoke it and even though at this moment you return them to me in a text field it will help me a lot, to pass this bump.
Thank you very much for everything before anything, and hopefully in the future I can share this knowledge with more people.