• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Beginning threads

Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not too sure if this should be in beginners or threads.. but I am looking at threads for the first time. Whilst I understand the theory behind a thread I am having problems implementing.

This is my test scenario.

One object that implements runnable with a run() that draws a splash screen.

Now in my main I want to run the splash screen, pause it, then build my gui and then hide the splash screen.
I do not want to use the sleep() method to pause my splash screen object as I want it to only hide once everything is done. This is my main:

This is the beginning run of my splash screen class

This is the pause bit in the splash screen class

Now the problem is the splash screen never gets to do its bit.. it never draws its screen, which I would imagine would be done by the run() when I call start in my main. It never shows the System.out.println("showing splash"); or the "waiting"!?!?

What am I doing wrong? Have I missed the boat entirely on Threads? Haveing real problems trying to get my head around this.. any bit of help would be much appreciated.

Thanks for reading

[ October 20, 2004: Message edited by: Martin Thorpe ]
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to your scenario I would do the following:
- in main method create the splash dialog
- form the splash dialog start a new thread to build the main window using SwingUtilities and taken care not to show it (you run in threading issues otherwise)
- return from the dialog the new initialized main window and just show() it.

Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic