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 / General / July 2006

Tip: Looking for answers? Try searching our database.

adding a jlabel to a jdialog...

Thread view: 
tiewknvc9 - 26 Jul 2006 15:30 GMT
seems like such a silly question...

but I have the code listed below, but for some reason my JLabel is not
showing up in the JDialog...  I dont know what the problem is... do
you?

JDialog jdgOpening = new JDialog(this, "Opening File......");
JLabel lblOpen = new JLabel("Please wait, opening file...");
jdgOpening.getContentPane().setLayout(new FlowLayout());
jdgOpening.getContentPane().add(lblOpen);
jdgOpening.setPreferredSize(new Dimension(200,80));
jdgOpening.setSize(new Dimension(200,80));
jdgOpening.setResizable(false);
jdgOpening.setVisible(true);
Michael Postmann - 26 Jul 2006 15:39 GMT
tiewknvc9 schrieb:
> seems like such a silly question...
>
[quoted text clipped - 10 lines]
> jdgOpening.setResizable(false);
> jdgOpening.setVisible(true);

what do you do after setting this dialog visible? If you don't work in a
 second thread the gui freezes until you finished opening the file. So
when the label get's displayed the file is finished opening and the
label is imediately disappeering from screen with your dialog...

lg
Nomike aka Michael Postmann
tiewknvc9 - 26 Jul 2006 15:57 GMT
Ah yes...

Ok so here's what I did to avoid making a second thread for something
this little.

After adding my jlabel to the jdialog object, I called
lblOpen.paintImmediately(0,0,200,80);

this made the screen refresh.  I would have considered something more
complex, but it is typically only visible for a 2 or 3 seconds.

Thanks for the help!

> tiewknvc9 schrieb:
> > seems like such a silly question...
[quoted text clipped - 19 lines]
> lg
> Nomike aka Michael Postmann
tiewknvc9 - 26 Jul 2006 15:57 GMT
Ah yes...

Ok so here's what I did to avoid making a second thread for something
this little.

After adding my jlabel to the jdialog object, I called
lblOpen.paintImmediately(0,0,200,80);

this made the screen refresh.  I would have considered something more
complex, but it is typically only visible for a 2 or 3 seconds.

Thanks for the help!

> tiewknvc9 schrieb:
> > seems like such a silly question...
[quoted text clipped - 19 lines]
> lg
> Nomike aka Michael Postmann
Vova Reznik - 26 Jul 2006 15:47 GMT
> seems like such a silly question...
>
[quoted text clipped - 10 lines]
> jdgOpening.setResizable(false);
> jdgOpening.setVisible(true);

It cannot be compiled, because setPreferredSize
isn't method of JDialog, but JComponent.
Without that line it works fine.
tiewknvc9 - 26 Jul 2006 15:59 GMT
fyi - it is valid in jdk 1.5

> > seems like such a silly question...
> >
[quoted text clipped - 14 lines]
> isn't method of JDialog, but JComponent.
> Without that line it works fine.
Andrew Thompson - 26 Jul 2006 19:16 GMT
> fyi - it is valid in jdk 1.5

Please refrain from top-posting - it is most confusing.

It might have been useful to post a compilable source, and
to mention that your snippets were compiled within a 1.5
SDK.

A quick scan of the code fragments you have posted,
with constant calls to setPreferredSize() and setSize(),
together with needing to set the preferred size of the
JDialog itself, and compounded by the need to call
paintImmediately() at all, indicates your GUI is in serious
trouble - and will probably not survive a different ..
 - Platform
 - PLAF
 - Java Release
 - End user settings or screen size/resolution.

If you post compilable code, we can begin to fix the problems.

Andrew T.


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.