Author Topic:   List Component..
psethura
ranch hand
posted April 08, 2000 03:12 PM         
My question:

List l = new List(3);
Here only 3 items are visible , I can have any number of items as I want.It will have a scroll bar unlike Choice component only one item is ALWAYS visible..

But i tried this code and it is not working..

Frame f = new Frame("Fun")
f.setSize(200 , 200);
List l = new List(3);
l.add("a");
l.add("b");
l.add("c");
l.add("d");
l.add("e");
f.add(l);
f.setVisible(true);

All choices are visible. why?
Am I missing something..

Thanks

maha anna
bartender
posted April 08, 2000 05:20 PM             
psethura,
The LayoutManager is the culprit. Can you tell what it does?
regds
maha anna.

psethura
ranch hand
posted April 08, 2000 05:27 PM         
Ok here is my understanding...
Default layout for frame - BorderLayout .When I add List component frame, it goes to center of borderLayout , N/E/W and South is dicarded. So..it is taking visual properties of Parent container, in this case Frame. Is it correct? If i change to FlowLayout it is working fien..

maha anna
bartender
posted April 08, 2000 05:56 PM             
Yes. You got it. The reason is BorderLayout doesn't honour (We can say partly honours) the preferred size of the components it contains. I said partly because, it gives the preferred width for East and West side components and preferred height for North and South side components. But for the components placed in 'Center' portion it doesn't care. Because center takes all the left-over from E/W/N/S components.
regds
maha anna

|