Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing data through a globally created table variable.

 
Anurag Parekh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the idea I have going here is that I have created a DefaultTableModel tablel as a Global variable. The table is then created and attached to a Grid bag layout. Then I want to call the table again in another method to add rows of data into it. Hopefully that makes sense.

So the addrow for the table is located in the final method private class CalcButtonListener implements ActionListener

When I debug the code, deftablemodel variable is carrying NULL data.

Also to make things even more complicated, The actual headers for the table aren't showing up,... not entirely sure why though.

 
Anurag Parekh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed it, I shouldn't have created the table at the start of the code...just made a Global Variable.
Then initialized... then it added the row.
 
Campbell Ritchie
Marshal
Posts: 52636
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I hope you did not really create a global variable. They should have no place in object‑oriented code.
 
Anurag Parekh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah it was my mistake with GV (global Variable)... I'm still fairly new at this and learning constantly... I'm sure I'll be back on here in the next week asking another noobish question,
 
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!