wood burning stoves 2.0
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

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?

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

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
It's not a secret anymore!