• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Frame components still remained after frame.dispose()

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 -
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic