File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Some code about GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Some code about GUI" Watch "Some code about GUI" New topic
Author

Some code about GUI

George Ren
Ranch Hand

Joined: Aug 17, 2002
Posts: 58
Hi,everyone.
Recently I am working on FBNS. First I created a dialog to allow user to select which model(Remote or Local)to use. I use JBuilder 9 to do the job, the .java file is compiled successfully, but when I run this gui, it displaies only the area of label of the window. I try to set size to the panel, but It seems don't work. Now I paste the code, please help me see it. Thanks.

[ October 01, 2003: Message edited by: Mark Spritzler ]

THINK!
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11278
    
  59

Hi George,
One problem is that since you do not have a layout manager for the panel, when you call the pack() method, the panel cannot calculate it's preferred size. If you set the panel's preferred size, that problem will be avoided.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
George Ren
Ranch Hand

Joined: Aug 17, 2002
Posts: 58
Thanks Andrew, I will try.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I would also look at your indentation of your code, and the variable naming. It appears a couple of places that it does not follow Sun's standards. And a variable name like "panel1" is a very bad name for that variable. variables should be more descriptive as to what it actually is.
I am also going to need to remove most of your code, just because it gives too much away to another test taker. I will leave the part of the code that relates to your question.
Thanks
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Dushy Inguva
Ranch Hand

Joined: Jun 24, 2003
Posts: 264
Hello George,
Its probably better to use a LayoutManager. Sun usually insists about using a LayoutManager.
As part of the requirements, you are supposed to provide a framework for GUI development. It would fit in better if you use a layout manager.
Thanks
Dushy


SJCP, SCBCD, SJCD, SCDJWS, SCEA (Part I)
George Ren
Ranch Hand

Joined: Aug 17, 2002
Posts: 58
Thank all of you for giving me the advice.
Mark, I will change the panel's name and I will not give out any code that doesn't relate to the problem.
Dushyanth,thank you for your advice. I will try to use a Layout manager in my implementation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Some code about GUI
 
Similar Threads
java.lang.OutOfMemoryError
Ultra noob problem
enabling & disabling menuitems
How do i know if a JFrame is iconified?
Text in Jcombobox is too small, but why?