• Post Reply Bookmark Topic Watch Topic
  • New Topic

Clearing old widgets and creating the same again on a button click

 
Madi Meka
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,


On a button click i am creating a table on a composite.
and wen i click agen i want to dispose this table and create again.
because everytime i click the button, new table gets created keeping the old one already on composite.

Hope I am clear.

Thanks,
Madhavee Latha

 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What toolkit are you using? Swing, SWT, or something else?

With Swing (and JTable), you just need to create a new (Default)TableModel, then use the JTable's setModel method. It will replace the old model of the table with the new model.
 
Madi Meka
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using SWT.
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think old_Table.dispose() should work, not sure though.

But you may also recreate the composite itself, so the entire previous heirarchy is disposed(I know it a bad idea....but it's an idea ;)
 
Vivekkk Singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it can be done .If you you are using one button just maintain the state of Button.And then switch it either to create or dispose Methods.

I think you get my point.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!