• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with Visibility of a frame after actionPerformed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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........
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic