aspose file tools*
The moose likes Java in General and the fly likes checking for an instance of an object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "checking for an instance of an object" Watch "checking for an instance of an object" New topic
Author

checking for an instance of an object

Deyna Cegielski
Ranch Hand

Joined: Nov 24, 2004
Posts: 60
i have a search function that returns a list of records from a database into a list, upon selecting of these records and pressing a button i want for it to be displayed fully in a user interface i have created to display that type of record.

the problem is, if an instance of this user interface already exists i dont want to create another instance (i.e. 2 windows), i would rather get hold of this instance and the use the technique i developed for putting data from the database into the user interface.

is there a way to check if an instance of a specific object (i.e. the user interface) already exists, and if it does get the focus on it, and if not then use the usual code to create a new instance?

thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18992
    
    8

First declare an instance variable for the class that wants to make this decision, and set it to null:At this point you don't have any instance of the user interface. Then to use the interface or create a new instance if necessary:and now the variable contains a reference to what you want.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: checking for an instance of an object