Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2004

Tip: Looking for answers? Try searching our database.

Problem with splash window (startup) (jwindow,jdesktoppane,jprogressbar)

Thread view: 
anders - 30 Jan 2004 14:43 GMT
Thomas Weidenfeller <nobody@ericsson.invalid> wrote in message news:<bvdgdq$nbr$1@newstree.wise.edt.ericsson.se>...
> anders wrote:
> > I do understand the atvantage of using AWT instead of Swing for
> > a startup window. But its rather useless until I've found a
> > solution for my 2 questions, until then I'll use the
> > suggested .setUndecorated(true);
>
> I suggest you better not rate the answers you get. Otherwise people
> might start to rate the source code you posted. And that will not be
> favorable for you.
>
> /Thomas

??? I didn't rate the answer, did I? I'm still looking for an answer
on my two questions. the ".setUndecorated(true);" does exactly the job
for me in a JFrame. But I also accept the 2nd answer that AWT is
better to be used, but there I have the flickering problems, hense I'd
like to get a solution for that too.
Please feel free to comment on my source code. I learn java myself
from books and I'm greatful to improve my skills.

I appologise to the two writers if they feel I was critic on them,
that was not the intention at all.

But I will put some critc towards you Thomas, who are you to play
Police here?
I think theese forums here are for people to learn.
Jon A. Cruz - 07 Feb 2004 05:04 GMT
> ??? I didn't rate the answer, did I?

Yes, you did.

> I'm still looking for an answer
> on my two questions. the ".setUndecorated(true);" does exactly the job
> for me in a JFrame. But I also accept the 2nd answer that AWT is
> better to be used, but there I have the flickering problems, hense I'd
> like to get a solution for that too.

First thing I noticed is that you're doing horrible abuses of threadding
there.

Your main() method is most probably on a different thread than the UI.
All UI operations *should* be done on a single thread ('the' UI thread),
so that's one source of problems.

Another point is null layout managers. Don't set the layout manager
null. Either use an existing layout manager or create a custom one.
Either of those will result in less code on your part and fewer bugs and
display anomalities. (So, among other things, you should never be
calling setSize(), setLocation(), etc ). [yes, there are exceptions, but
they should be treated as not the desired approach]

Next minor point:
   window.show();
and
   window.setVisible(true);
do the same thing.

Oh, and aside from doing all UI work on the UI itself, one main point is
to *never* sleep on the UI thread.

And, sleep() is actually a static method, so
    Thread ct = Thread.currentThread();
    try
    { ct.sleep(mili); }
    catch(IllegalArgumentException e){}
    catch(InterruptedException e){}
should be
    try
    { Thread.sleep(mili); }
    catch(InterruptedException e){}

Anyway...

* Have a main() that *only* creates an AWT splash frame. Ensure that
there are no references to classes in the rest of your app there.

* Once that's up, use reflection to get the real main access point to
your application. (Call from the splash on the UI thread once the splash
screen is displayed)

* Spawn a new thread to do creation of your new app. Pass it an
interface for status updates to call back the AWT splash with.

* Make sure that in your main creation you use
SwingUtilities.invokeLater() to get updates back to the AWT splash.
Don't call that interface directly from the construction thread (since
by design it will *not* be the UI thread)

* To get sizes in your construction, call pack() on your frames after
they've been constructed and *before* they're to be displayed.

* Maybe have a call on your splash interface that passes the AWT splash
screen the instance of your app's main window to display, but ensure
that it does the switchover on the UI thread.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.