Author Topic:   Should we consider this also as platform dependent?
maha anna
bartender
posted April 24, 2000 07:48 AM             
Hello all,
In Jxam, one of the qstns asked say tru/false about 'java.awt.List' related info. The author says the foll is false.

Possible Answer 3:
A vertical scroll bar will be added automatically if needed.

I thought List will have scroll bars if needed, since I have seen in some GUIs. So I checked the SAME example given in Java Doc. In JavaDoc the image shown DOES NOT show scroll bars. But when I tested the same example on Win 98 , JDK 1.2.2, it shows the scroll bars. So what do we say if this kind of qstns come up in the Exam.

Thank you all.
regds
maha anna

Please refer to the online Java Doc here,



import java.awt.*;

class mframe extends Frame{
public mframe(){
setLayout(new FlowLayout());

List lst = new List(4, false);
lst.add("Mercury");
lst.add("Venus");
lst.add("Earth");
lst.add("JavaSoft");
lst.add("Mars");
lst.add("Jupiter");
lst.add("Saturn");
lst.add("Uranus");
lst.add("Neptune");
lst.add("Pluto");
add(lst);


setSize(400,300);
setVisible(true);

}

public static void main(String args[]){
new mframe();
}
}

[This message has been edited by maha anna (edited April 24, 2000).]

bongadi
greenhorn
posted April 24, 2000 08:44 AM             

Hi!

The figure in the jdk1.2 api docs is misleading.
The scroll bars should appear otherwise how would you select
other items (i.e. other than the four which are displaying).

However if you increase the # of rows to be displayed in c'tor
the to be more or equal to # of items in the list c'tor
like: List lst = new List(13,false); then
the scrollbar disappears (at least on Solaris X86 2.6).

bongadi

satya5
ranch hand
posted April 24, 2000 08:57 AM             

Maha:

If I remember the question correctly, the code given
in the exam doesnot add anything to the list.
It says something like:

List lst = new List(X, false);

Then the answers given are (something like this):

A. multiple items can be selected
B. Max. "X" items are visible.
C. scroll bar is added automatically, if needed
D. Only "X" items can be added to the list.

I think the code does not add any items to the list.
Hence there is no need to add any scroll bar automatically.

I told this to myself and agreed with the author of the exam.

Re your example, I think the scroll bar is added (if needed)
irrespective of the machine it runs. I am on UNIX and it did
add a scroll bar.


Regds.

- satya

|