Solved

load a frame once

Posted on 2003-12-02
5
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 64
What is the use of Forwarding Class in java 1 37
Java array sort 10 35
Strange router problem - can't access hotmail.com 14 55
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 …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

726 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