Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Any ideas or concepts??  RSS feed

 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gurus,
I am having a parent class(ParentWin), inside this i
will create an object of child class(ChildWin).
My requirements comes like if i create one more instance of parent class(ParentWin),child class should not be created.Once an object of child class(ChildWin)is created it should not be instantiated again..Can you please suggest for single instance
of childWin at any point of time...

ParentWin---- mainwindow
ChildWin ---- childwindow created
from main window.
So when i create one more instance of Parent window( 2nd instance) and try to create child window, the earlier created child window should be shown, so new creation should happen

advance thanks for Suggestions.
Thanks&Regards,
selva.
 
PierreArnaud Galiana
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mmh, looks like you need to implement the singleton pattern... (and this has nothing to do with Swing/JFC/AWT)
have a look here:
GoF singleton pattern
Singleton in Java
your ChildWin will implement the singleton pattern, and when ParentWin wants to get a ChildWin, it will call the instance() method
[This message has been edited by PierreArnaud Galiana (edited June 23, 2001).]
 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi PierreArnaud,
thanks for this useful site.
Regards,
silva.
 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi PierreArnaud ,
thanks for the reply and i had implemented it.
Regards,
silva.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!