A java.awt.List (Solaris Motif version) object has the correct size when it is created, but as items are added, it changes its height. These size changes are not reflected in the java object's internal variables; it still thinks it has the original size. Using xwininfo -tree clearly shows that the widget's window actually is changing size.
Try the following code, with the following html tag. It creates a list and adds a line to it every 5 seconds. It prints out the List's own idea of its size initially and after each line is added. This information never changes, which shows that java is not aware that the object is changing size. Yet the resizing is quite obvious. Also try xwininfo -tree.
<applet code=ListDemo.class width=200 height=200> </applet>
import java.applet.*;
import java.awt.*;
public class ListDemo extends Applet
implements Runnable
{
List list;
Thread t;
public void init()
{
list = new List(8,false);
add(list);
t = new Thread(this);
t.start();
}
public void start() {}
public void stop() {}
public void destroy() {t.stop();}
public void run()
{
int count = 0;
try
{
System.out.println("list.bounds() = " + list.bounds());
while (true)
{
Thread.sleep(5000);
list.addItem("Item " + count);
count++;
System.out.println("list.bounds() = " + list.bounds());
}
}
catch (InterruptedException e)
{
System.err.println("Interrupted!");
}
}
}
Try the following code, with the following html tag. It creates a list and adds a line to it every 5 seconds. It prints out the List's own idea of its size initially and after each line is added. This information never changes, which shows that java is not aware that the object is changing size. Yet the resizing is quite obvious. Also try xwininfo -tree.
<applet code=ListDemo.class width=200 height=200> </applet>
import java.applet.*;
import java.awt.*;
public class ListDemo extends Applet
implements Runnable
{
List list;
Thread t;
public void init()
{
list = new List(8,false);
add(list);
t = new Thread(this);
t.start();
}
public void start() {}
public void stop() {}
public void destroy() {t.stop();}
public void run()
{
int count = 0;
try
{
System.out.println("list.bounds() = " + list.bounds());
while (true)
{
Thread.sleep(5000);
list.addItem("Item " + count);
count++;
System.out.println("list.bounds() = " + list.bounds());
}
}
catch (InterruptedException e)
{
System.err.println("Interrupted!");
}
}
}