This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Set Table row data in to a form by action listener  RSS feed

 
Ranch Hand
Posts: 155
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
Rancher
Posts: 2887
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!