• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with Visibility of a frame after actionPerformed

 
Chichi Gautam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a simple login window

and in the actionPerformed of the Login Button
I have to a lot of initialization for my application.

But i want my Main Frame to be visible as soon as i click Login button

This MainFrame is having a menu bar and different images

Each of the tasks in actionPerformed are as separate threads.

But my MainFrame is shown as complete gray frame...(though all the images are
loaded)

and is completely visible with its components ONLY at the end of ActionPerformed

Can anyOne help me out of this..


I want to display the frame as soon as i click Login button.

Thanks in advance
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
without any code it is difficult to interpret how you are putting it all together.

one option might be to load/build your gui while the login screen is showing,
then, if login successful
loginScreen.dispose();
frame.setVisible(true);

but, depending on exactly what you are doing, this still might not be satisfactory.

can you post a sample program that demonstrates the problem - just enough
code so we can copy/paste/compile/run and see it happening
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you setting the Frame visible before all the components in the constructor are added? That might be the explanation.
A validate() call as the last statement inthe constructor might sort it out.
 
Chichi Gautam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both of you.

Now what I did is the code someWhat like this

public void actionPerformed(ActionEvent evt)
{
LoginFrame.setVisible(false);


Thread LoginThread=new Thread()
{
public void run()
{
LoginInit();
}
};
LoginThread.setDaemon(true);
LoginThread.start();
}

where LoginInit() does all the login and initialization process.

Also it has
if(IsImageLoaded)
{
MainFrame.setVisible(true);
}


This also contains the adding of few components to MainFrame.

Now as soon as I say Submit and reach MainFrame.setVisible(true)
I can view the MainFrame .

This mainFrame was shown Gray previously, until ActionPerformed is completed.

Well, Thanks to java ranchers........
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!