Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

regarding repaint() in JTabbedPane  RSS feed

 
Thamu Gurung
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a tabbedpane , which has 2 panes(panels), with following specifications:

First Pane - Registeration form and add record button , which is writing the new record into database.
Second Pane- Displays the datas in JTable

when i click to "add record" button the data is written in to the database , no problem , but when i switch to Second Pane , it displays the same old data. If I'm running the program again then the data is displayed .

I tried by placing a button in Second Panel "re-load table" , and handled it simply like this
whichi s also not working ....

I tried with ChangeListener(state changed) of JTabbedPane but got confused .

I want that when the user has added a record from the first Pane , and the moment he switches to Second Pane ,the just added datas to be displayed automatically.

Appreciate your kind help

Regards


 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you actually change the content of the JTable? You know, either change its model (setModel) or update the existing model?
 
Thamu Gurung
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Rob,

Again changing the Model , will be complicated for me.

Is there any method of repainting the panel when that particular tab is selected containing that panel ?

or is it associated with the event of the "Add Record " in pane 1 ???

Regards ,


 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again changing the Model , will be complicated for me.


Changing the model is no more difficult than it is to create the model the first time. As Rob suggested above its a two step process:

a) create the model
b) use table.setModel( newlyCreatedModel );

Since you say the model alreaday displays data from the database you obvious know how to create a model. So its just a matter of adding a setModel() statement everytime you add a record on the first tab or select the second tab. The choice is up to you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!