• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Need Advice

 
Ranch Hand
Posts: 240
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi;

I am trying creating a swing application. Basically the client connects to a database and than is giving various options for customizing and creating reports with different views of the data.

My first idea was to use the JTabbedPane. Each tab would be associated with a pane. The method that creates the pane would create its contents depending on whether the client was connected or not when they clicked the tab.

I thought I could create a ChangeListener class and add it to my JTabbedPane. Everytime you changed tabs it would regenerate all the panels associated with each tab and than repaint the JTabbedPane. Thus all the interfaces would be constantly refreshed with current data (or nothing if they are not connected to the database).

The problem is the view of the panel never changes from when it was first created.

Here is my method that handles tab changes:

class TabListener implements ChangeListener {

/*
* Each time someone clicks a tab recreate all the panels
* and redraw the tabbedpane to refresh all the views.
* once this works refine it to only redraw the panel
* that is selected
*/
public void stateChanged(ChangeEvent e) {
//create the panels again
createMainPane();
createAuctioneerDataPane();
createAuctionDataPane();
createAuctionPane();
createAuctioneerPane();
createUpdatePane();
//repaint the tabbedpane
tabs.repaint();
}

}

Is there a better way to do this? Anyone ever done anything like this before?

Thanks,

Luke
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Luke,

Originally posted by Luke Shannon:
Hi;

I am trying creating a swing application. Basically the client connects to a database and than is giving various options for customizing and creating reports with different views of the data.

My first idea was to use the JTabbedPane. Each tab would be associated with a pane. The method that creates the pane would create its contents depending on whether the client was connected or not when they clicked the tab.

I thought I could create a ChangeListener class and add it to my JTabbedPane. Everytime you changed tabs it would regenerate all the panels associated with each tab and than repaint the JTabbedPane. Thus all the interfaces would be constantly refreshed with current data (or nothing if they are not connected to the database).

The problem is the view of the panel never changes from when it was first created.

Here is my method that handles tab changes:

class TabListener implements ChangeListener {

/*
* Each time someone clicks a tab recreate all the panels
* and redraw the tabbedpane to refresh all the views.
* once this works refine it to only redraw the panel
* that is selected
*/
public void stateChanged(ChangeEvent e) {
//create the panels again
createMainPane();
createAuctioneerDataPane();
createAuctionDataPane();
createAuctionPane();
createAuctioneerPane();
createUpdatePane();
//repaint the tabbedpane
tabs.repaint();
}

}

Is there a better way to do this? Anyone ever done anything like this before?

Thanks,

Luke



You might need to call tabs.validate or whereever is required, if the components are reorganized or modified or if the layout is changed. This should change the previous view.
If it still doesnot work, would you post your code to have a glance?
- Sai
 
Luke Shannon
Ranch Hand
Posts: 240
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sai;

Good call. That works perfectly. Thanks for the help.

Luke
 
Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic