It's not a secret anymore!*
The moose likes Java in General and the fly likes Tracking java objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Tracking java objects" Watch "Tracking java objects" New topic
Author

Tracking java objects

ramdas pradeep kumar
Ranch Hand

Joined: Aug 27, 2003
Posts: 36
hai there,
how to know whether an object of a class presently invoked. for example i am opening a frame by clicking a button. without closing that i opened another frame. now how can i know whether a frame is opened previously.

pradeep
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
Hi Ramdas
The first thing comes to my mind is you can extends the Frame/JFrame and make your custom frame object and make it "singleton".
In case you are not aware of how singleton works...
public class MyFrame extends JFrame {
private static MyFrame myFrame;
private MyFrame() {
}
public static getInstance() {
synchronized(MyFrame.class) {
if ( myFrame == null) {
myFrame = new MyFrame();
}
}
return myFrame;
}
}

Please let me know if I unncessarily confused you.
Also, this is what I get from top of my mind. I don't know if you can somehow make Frame "modal" as Dialog boxes...It has been while I did any UI..
Regards
Maulin
Gayathri Prasad
Ranch Hand

Joined: Jun 25, 2003
Posts: 116
Hi,
How abt statica variable which keeps the count of the object. For frames when we close the frame then we decrement the static variable. This jus my personal opinion feed back would certainly help me.'
Cheers,
Gaya3
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I did a PB project with MDI interface and a lot of pop ups. When closing the frame we had to know the status of all the subwindows. So we made a window manager with methods to open and close windows that also kept a collection of what's open.
Nowadays I'd use a pub-sub style solution where windows register themselves for "about to close" events. If a window was not in a closeable state, it could respond in a way that makes the publisher stop trying. My Messaging Patterns page mentions this technique. You'd have to write your own publisher - the standard Observable doesn't act on results from events it sends out.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I did a PB project with MDI interface and a lot of pop ups. When closing the frame we had to know the status of all the subwindows. So we made a window manager with methods to open and close windows that also kept a collection of what's open.
Nowadays I'd use a pub-sub style solution where windows register themselves for "about to close" events. If a window was not in a closeable state, it could respond in a way that makes the publisher stop trying. My Messaging Patterns page mentions this technique. You'd have to write your own publisher - the standard Observable doesn't act on results from events it sends out.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Tracking java objects
 
Similar Threads
closing a page with 3 frames
closing a frame
Using Javascript to Close Windows
Internet Explorer
How to launch a webpage from a browser from an application and an applet