It's not a secret anymore!*
The moose likes Swing / AWT / SWT and the fly likes JFrame Calls.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame Calls.." Watch "JFrame Calls.." New topic
Author

JFrame Calls..

Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Hi friends..

i have a little question, iam trying to develop an simple Swing based application by using Netbeans 6.0.1
i have 2 classes which extended JFrame, and 1 main class..
i have a problem when, first JFrame call another JFrame and then recall back the first JFrame..

in my main class, i just putted :


when MainJFrame calling another JFrame, i was use..


it will force Java always to instantiate a new class (new objects instantiated)..
so the frmInsert could be instantiated multiple..

how to restrict it?, say that i want to just use setVisible method to handle it..
i want all of my JFrame classes only instantiated once time..

do i have to instantiate all of my JFrame Classes in my Main Class?..
maybe with the code :

is that good understanding?..

so how to call an object in memory (JVM) from MainJFrame (my JFrame active class)?
example i want to call a (object class which referenced by Other1Class) by click a button in MainJFrame..

Thanks in advance..


Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Pierre Sugar
Ranch Hand

Joined: Dec 08, 2002
Posts: 62

# frmInsert f=new frmInsert();
# f.setVisible(true);


try lazy initalization


Pierre
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Pierre's advice is good. Also, are you sure that you want to have two JFrames associated with your app? Most apps I've seen have one main JFrame and several JDialogs. This can make it much easier if you want to open a window in a modal fashion.
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Thanks for your advice, Pierre Sugar and Pete Stein ..

alright, i will use only one JFrame, and another i will use JDialog..
hmm, if i want to build any Splash Screen (Splash Form with progress bar), and form login after Splash Form shown..
do i have to use JDialog for Splash Screen and form login also?..
if the application just use one JFrame, then another form use JDialog,
so where is the good implementation for JFrame?.. is that in Main Form?..

if i use lazy initialization for all my JDialog and JFrame also, is it a good implementation?
or does most application developed by using lazy initialization..

Thanks for advance..
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Leonardo Carreira wrote:alright, i will use only one JFrame, and another i will use JDialog..
hmm, if i want to build any Splash Screen (Splash Form with progress bar), and form login after Splash Form shown..
do i have to use JDialog for Splash Screen and form login also?..


For a Splash screen, you may wish to look at the Sun Swing tutorial section on splash screens. You can find it here: Splash Screen Tutorial
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Sorry before, Iam still confuse about JFrame calling

now, i have 1 JFrame and 3 JDialog..
how to make all of that object be like a global variable?..
in mean, that all of the JDialog can call JFrame then set the JFrame's property

example i want to build the application flow, when the JTable in that JDialog double clicked then the value of the row in that JTable, automatically setted to JFrame's property, assume JTextField..
or maybe the values would be setted to another JDialog..

so how to call other JDialog from a JDialog, or JDialog call JFrame, or JFrame call JDialog which not must be instantiate first?..

so i just put the code like this :


it look like VB programming..
how to make it?
do i have to set with static attribute for all of the properties?..

Thanks in advance..

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame Calls..