Scroll menu out of control problem
Guys
I have created a scroll menu, everything seems ok except when you click on the arrows, it never stops. I tried everything but can not find which component gets the event. Any suggestion will be appreciated.
Thanks
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
public class NewJFrame extends javax.swing.JFrame {
private JMenuBar menuBar;
private JMenu menu1;
public static void main(String[] args) {
NewJFrame inst = new NewJFrame();
inst.setVisible(true);
}
public NewJFrame() {
super();
initGUI();
}
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig",
"Fish", "Horse", "Cow", "Bee", "Skunk" };
JList list = new JList(petStrings);
JScrollPane scrollPane = new JScrollPane(list);
menuBar = new JMenuBar();
setJMenuBar(menuBar);
menu1 = new JMenu();
menuBar.add(menu1);
menu1.setText("menu1");
menu1.add(scrollPane);
pack();
setSize(400, 300);
} catch (Exception e) {
e.printStackTrace();
}
}
}

