Sunday, 18 August 2013

Display only one selected or requested jpanel in swing application

Display only one selected or requested jpanel in swing application

I am making an application in swing. I have more than 20 jpanel. I want to
display that jpanel to which I want display :
example:
WelcomePanel welcomePanel = new WelcomePanel();
BindingDetailsPanel bindingDetailsPanel = new BindingDetailsPanel();
FooterMainPanel footerMainPanel = new FooterMainPanel();
KeyMessageSetupPanel keyMessageSetupPanel = new KeyMessageSetupPanel();
SMSCSetupPanel sMSCSetupPanel = new SMSCSetupPanel();
LiveProcessorDetailsPanel runTimePanel = new LiveProcessorDetailsPanel();
RuntTimeInformationPanel welcomePanel=new RuntTimeInformationPanel();
BlockedSmscDetailsPanel blockedSmscDetailsPanel = new
BlockedSmscDetailsPanel();
I am making object of above listed panel in my main jFrame. It is working
fine
because:
public mainFrame(){
requestResponseReportPanel.setVisible(false);
keyMessageSetupPanel.setVisible(false);
sMSCSetupPanel.setVisible(false);
welcomePanel.setVisible(true);
keyMessageDetailsPanel.setVisible(false);
blockedSmscDetailsPanel.setVisible(false);
runTimePanel.setVisible(false);
}
first time when my application starts it will display only one panel
welcome panel which I am making visible welcomePanel.setVisible(true); and
I have menu if I click it should be display keyMessageSetupPanel following
is code to display this panel:
private void
keyMessageSetupMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
try {
mainFrameContentPanel.add(keyMessageSetupPanel, BorderLayout.CENTER);
keyMessageSetupPanel.setVisible(true);
sMSCSetupPanel.setVisible(false);
welcomePanel.setVisible(false);
homeButton.setVisible(true);
bindingDetailsPanel.setVisible(false);
requestResponseReportPanel.setVisible(false);
keyMessageDetailsPanel.setVisible(false);
blockedSmscDetailsPanel.setVisible(false);
} catch (Exception e) {
printStackTrace();
}
}
My question is if I used like this my application is working. But it loads
all panel at runtime and takes long time to load. If I did not like this
it displays welcomePanel and if I went to another panel by clicking ( menu
or button ) :
Example:
Welcome Panel displays
I went keyMessageSetupPanel (This is working fine)
Now I went to bindingDetailsPanel (it works)
But the problem is I want again to keyMessageSetupPanel (it does not hides
the bindingDetailsPanel).
Please help me. Note If you do not understand comment where you did not
understand my question I will try to explain.
Thanks

No comments:

Post a Comment