Forums Register Login

Set Table row data in to a form by action listener

+Pie Number of slices to send: Send
Hi ranchers....
I'm doing a swing application.
I have a  Table and input form.What I want to do is when I click a row in the table The input form must fill with the data that table row has.
I created my own table model by extending Default table model.
this is a part of that TableModel.java





this is how I call my action listener by click a row

;

this is the setDataToInsertPanel method in Input form



 
  When I debug my prgram I found that my Arrry index bound exception is occur inside the getSelectedData(selectedRow) method.
please some one help me to get out from this problem.



+Pie Number of slices to send: Send
 

I created my own table model by extending Default table model.



The DefaultTableModel already provides data storage and methods to access the data. You typically only extend DefaultTableModel to override methods like getColumnClass(...), isCellEditable(...) to change the default behaviour of the model.

If you want to store a custom object then you should be extending AbstractTableModel and you then need to implement all the methods of the TableModel interface to access the data in your custom model.

Check out the Row Table Model for a step by step example on how to create a custom model.
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 217 times.
Similar Threads
JTable related problem
Using ListSelectionListener
lost focus in JTable
JTable � handle Row lost focus event
JTable selection listener doesn't listen to column changes
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:24:14.