Solved

load a frame once

Posted on 2003-12-02
5
185 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
Comment Utility
you need to change the code that actually create F.
Keep an instance to F, and reuse it.
0
 

Author Comment

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

Accepted Solution

by:
objects earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now