• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFrame Calls..

 
Leonardo Carreira
Ranch Hand
Posts: 489
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Pierre Sugar
Ranch Hand
Posts: 62
Java Ruby Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
# frmInsert f=new frmInsert();
# f.setVisible(true);


try lazy initalization
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 489
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic