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 / December 2007

Tip: Looking for answers? Try searching our database.

JComboBox

Thread view: 
Ouabaine - 15 Dec 2007 15:41 GMT
Hello all,

I am programming the ComboBox object of my game creator. So I create a
JComboBox, and adds it to a JPanel which has a layout manager to null. So I
ask for the preferredsize of the combo, and do a setbounds at the wanted
coordinates with the preferred size. The JPanel is set to opaque (as
indicated in Java tutorials).
But I am facing a very strange problem : the top line of the combo box is
not properly drawn. In non-editable mode, the text of the selected element
is drawn, but the arrow (to open the combo) is not drawn. And in editable
mode it is worse, just a gray line is drawn.
But the combo reacts to the mouse, I can click on the gray line to open it,
and the list is displayed.

Have you got any idea about why I get this result? I've been scratching my
head and trying various things with no success. Would it be related to the
fact that my JPanel has a layout manager to null?

If anyone could have an idea...

Francois
Roedy Green - 15 Dec 2007 18:27 GMT
> Would it be related to the
>fact that my JPanel has a layout manager to null?

That sort of programming is highly discouraged in Java.  The more
Javaesque way it to use a layout or multiple layout managers, writing
a custom layout manager or two if necessary.  See
http://mindprod.com/jgloss/layout.html

When you use a null layout manager, you must:

1. manually set the size of every component, width and height.

2. manually set the position of every component, x and y.

3. makes sure the size and position of the container is suitable. You
either set them manually too, or define the min, max, preferred sizes
of the container so the container will be sized and placed in its
layout.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



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



©2009 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.