Solved

load a frame once

Posted on 2003-12-02
5
188 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

789 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