• Post Reply Bookmark Topic Watch Topic
  • New Topic

Frame components still remained after frame.dispose()

 
Akira Ross
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
I have a frame which consists of menu pane(Jmenu), action panel(buttons for popups), navigation panel(buttons) and content pane. When a user log in, he can see his own set of menu,action panel etc.. and when he logout, i use frame.dispose() to clean up the old frame. However, when he login as different user(basically a new frame with new components created), some components of the old frame still remain in the new frame.
I tried to set the oldframe to null after dispose and yet still couldn't solve my problem. I wonder why the components still remained even the frame was dispose and how can I solve this problem?
Can anybody help me on this? Thank you!
- akira -
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would really depend on how you are creating your components. If you are calling methods to generate them, it could be that you are calling a method incorrectly or too many times. Without some code to look at, it is a little hard to deduce.
Maybe you could post some code?

------------------
Happy Coding,
Gregg Bolinger
 
Akira Ross
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gregg ,
below is how my code look like:
public class MyContainer{
JFrame jfRender_;
.....
public void deleteFrame(){
jfRender_.dispose();
jfRender_.removeNotify();
}
}
public class MyFrame extends JFrame{
// the jfRender_ in MyContainer will be passed into constructor
public MyFrame(Jframe containerFrame){
parentFrame = containerFrame;
MyActionPanel aMyActionPanel = new MyActionPanel();
MyNavPanel aMyNavPanel = new MyActionPanel();
MyMenu aMymenu = new MyMenu();
MyContentPane aMyContentPane = new MyContentPane();
parentFrame.getContentPane().add(aMyActionPanel);
//add other components too
}
.....
public void dispose(){
super.dispose();
this = null;
parentFrame.deleteFrame();
}
}
When the user logout, dispose() in MyFrame will be called.
When the user login as different identity, new class OtherFrame (same as MyFrame) was created. Components of OtherFrame still added to the same jfRender_ of MyContainer.
Is my code wrong?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!