JScrollBar 在JDialog中 为JScrollBar添加AdjustmentListener 不起作用
JDialog f;
JScrollBar j1;
f=new JDialog(form,"查找",true); //form为当前窗体
f.setModal(true);
j1=new JScrollBar(JScrollBar.HORIZONTAL,0,5,0,255);
j1.setBounds(50, 50, 300, 15);
f.setLayout(null);
f.setBounds(100, 100, 400, 300);
f.add(j1);
f.setVisible(true);
j1.addAdjustmentListener(new AdjustmentListener(){
public void adjustmentValueChanged(AdjustmentEvent arg0) {
JOptionPane.showMessageDialog(f , "heh","huhu",JOptionPane.INFORMATION_MESSAGE);
}
});
当拉动j1这个JScrollBar JOptionPane.showMessageDialog(f , "heh","huhu",JOptionPane.INFORMATION_MESSAGE);
这句话没被执行
[解决办法]