Solved

load a frame once

Posted on 2003-12-02
5
187 Views
Last Modified: 2010-07-27
Im using the code below to load a frame every time a user opens the class file concerned with the following code. But I want the frame only to be loaded once, just when the user loads the class for the first time, and the for the class to be dynamically updated. The if statement im tyring to use throws an error when a second user trys to concurrently load the class file. Any help would be great, thanks.

public F(int NO){
            super("F");
            if(NO == 0){//this flag causes an error
            dis = new TextArea(20 , 10);
                  add("Center" , display);
          resize(300 , 150);
          show();
            }      
0
Comment
Question by:Ronayne
  • 3
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9863631
you need to change the code that actually create F.
Keep an instance to F, and reuse it.
0
 

Author Comment

by:Ronayne
ID: 9863644
Im creating different instances of f for different parameters passed in variable NO
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 9863663
would a Hashtable on frames help you:

private Hashtable frames = new Hashtable();


public F getFrame(int no)
{
   Integer _no = new Ineteger(no);
   F result = (F) frames.get(_no);
   if (result==null)
   {
      result = new F(no);
      frames.put(_no, result);
   }
   return result;
}
0
 
LVL 3

Expert Comment

by:InNoCenT_Ch1ld
ID: 9863961
does the question mean the instance of the frame can be open one at a time?

i try this using JInternalFrame.

set
-doDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); for the frame
-when you want to frame to be open, use setVisible(true);

i successfully restrict the frame to be loaded one at a time.

Feel free to discard this comment if this is not what you asking ;)

-Child that so pissed off!-
0
 
LVL 92

Expert Comment

by:objects
ID: 9959144
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question