File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Some code about GUI

George Ren
Ranch Hand

Joined: Aug 17, 2002
Posts: 58
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 ]

Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11776

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

Joined: Feb 05, 2001
Posts: 17276

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.

Perfect World Programming, LLC - iOS Apps
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.

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:
subject: Some code about GUI
It's not a secret anymore!