strange JScrollPane problem in JApplet
I've got a JApplet which is giving me a strange problem with the scrollbar of a JScrollPane.The JScrollPane is populated with a JList whose ListModel is a DefaultListModel. I specify to always show the vertical and never show the horizonatal scroll bars.
Once the JList content goes beyond the visible range of the viewport, it seems to be working as usual - the scrollbar reflects the amount of content. However, if I click on the scroll arrows, nothing happens. And, if I click on the scroll bar itself, it disables. Basically, the scrolling portion of the component dies. I don't get any exceptions during runtime or problems compiling the code.
I've tried making the ListModel and JList as dynamic elements (i.e. not members of the class). I've tried adding .validate(). I've tried everything of which I can think. I'm at a loss. The most troubling part of this is that if the project is set up as an application instead of an applet, it works fine.
I'm using J2 1.6.
Here's sample code that reproduces the problem:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
publicclass ScrollTestextends JApplet
{
private DefaultListModel exOddLM;
private JListexOddJL;
private JScrollPaneexOddSP;
private JButton click;
public ScrollTest(){
this.setup();
}
publicvoid init(){
this.setup();
}
publicvoid setup(){
this.setLayout(null);
this.setSize(400, 442);
this.exOddLM =new DefaultListModel();
this.exOddJL =new JList(this.exOddLM);
this.exOddSP =new JScrollPane(this.exOddJL);
this.exOddSP.setBounds(0, 0, 200, 200);
this.exOddSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
this.exOddSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
this.click=new JButton("add more");
this.click.addMouseListener(new MouseAdapter(){
publicvoid mouseClicked(MouseEvent me){ addMore();}
});
this.click.setBounds(0, 200, 200, 18);
this.add(this.exOddSP);
this.add(this.click);
}
privatevoid addMore(){
for(int x = 0; x < 5; x++){
this.exOddLM.addElement(Integer.toString(x));
}
}
}

