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