3 Replies - 397 Views - Last Post: 03 February 2011 - 04:52 PM Rate Topic: -----

#1 ScottH323  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 03-February 11

Adding Rows to a second Jtable based on the amount of rows in the firs

Posted 03 February 2011 - 03:15 PM

I currently have 2 Jtables, the first (JTable1) is filled through via a database than my aim is to get the amount of rows from the first table and then use that to add the same amount of rows into the second table as booleans so that the user can define wether the statemnts are true or fales. all of this i have managed to do apart from the part of getting the rows in the second table to match the first and then adding the booleans.

I know how to atually get the adding of rows to work by using
model.addRows(new Boolean(false));

but as im using netbeans and its GUI creator i cant seem to create the defaultTableModel needed so that i can atually do this and i was wondering if anyone could help me do this?

help would be much appreciated

Is This A Good Question/Topic? 0
  • +

Replies To: Adding Rows to a second Jtable based on the amount of rows in the firs

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10821
  • View blog
  • Posts: 40,346
  • Joined: 27-December 08

Re: Adding Rows to a second Jtable based on the amount of rows in the firs

Posted 03 February 2011 - 03:43 PM

If you're using the NetBeans GUI Builder, you're on your own. It produces code that none of us can read nor maintain. Really, Swing is easy enough that you should be writing all your code by hand. We are happy to help you with code you wrote.
Was This Post Helpful? 0
  • +
  • -

#3 ScottH323  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 03-February 11

Re: Adding Rows to a second Jtable based on the amount of rows in the firs

Posted 03 February 2011 - 03:47 PM

yes i would rather use normal swing but the project has over 60 panels and god knows how many buttons and the GUI builder seems to be alot more efficient at doing this :/

im currently trying to use this in order for it to work:
        for(int i = 0; i < 3; i++) { //using 3 just for testing, this would be the rows of jTable1 otherwise
            System.out.println("tableModel adding row");
           tableModel.addRow(new Object[]{new String("Works!")});
        }



but it doesnt seem to work despite putting
jTable2.setModel(tableModel);
into the jTable, could it be because its conflicting with the generated defaultmodel or am i just being a coding idiot again?
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10821
  • View blog
  • Posts: 40,346
  • Joined: 27-December 08

Re: Adding Rows to a second Jtable based on the amount of rows in the firs

Posted 03 February 2011 - 04:52 PM

I can't tell from the information presented what's going on. While I understand that you're working on a large project, the GUI Builder will hinder rather than help for the long term. Even if you have a lot of GUI components, better to write the code by hand. It will allow you to write more modular and reusable components, as well as cleaner and more maintainable code. :)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1