• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unknown number of rows to create a JTable

 
Aj Maffei
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am currently working on a project that requires me to have a JTable with 6 collums but a variable amount of rows. I know that you can use DefaultTableModel.addRow(), but the problem is that i am using NetBeans IDE to auto generate the GUI and it will not let me use the DefaultTableModel.

The auto generated code for the table is as follows:


Keep in mind i am not an excellent programmer I am looking to learn.
Help is very much appreciated,
AJ
 
Rob Camick
Ranch Hand
Posts: 2600
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jTable1.setModel(new javax.swing.table.DefaultTableModel(


According to that line of code it is using the DefaultTableModel.

You can access it in your code using:



 
Aj Maffei
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:
jTable1.setModel(new javax.swing.table.DefaultTableModel(


According to that line of code it is using the DefaultTableModel.

You can access it in your code using:





Simple enough... i forgot to cast it as a DefaultTableModel.
Thanks for the help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic