有时郁闷就是不知道这个组件有哪些对应触发事件可以调用。

解决方案 »

  1.   

    别郁闷,先找找文档,property出来的时候大家不也是先看文档的嘛。没有几个是先去扣源码就可以做什么的了
      

  2.   


    static final int FPS_MIN = 0;
    static final int FPS_MAX = 30;
    static final int FPS_INIT = 15;    //initial frames per second
    . . .
    JSlider framesPerSecond = new JSlider(JSlider.HORIZONTAL,
                                          FPS_MIN, FPS_MAX, FPS_INIT);
    framesPerSecond.addChangeListener(this);//Turn on labels at major tick s.
    framesPerSecond.setMajorTickSpacing(10);
    framesPerSecond.setMinorTickSpacing(1);
    framesPerSecond.setPaintTicks(true);
    framesPerSecond.setPaintLabels(true);public void stateChanged(ChangeEvent e) {
        JSlider source = (JSlider)e.getSource();
        if (!source.getValueIsAdjusting()) {
            int fps = (int)source.getValue();
            if (fps == 0) {
                if (!frozen) stopAnimation();
            } else {
                delay = 1000 / fps;
                timer.setDelay(delay);
                timer.setInitialDelay(delay * 10);
                if (frozen) startAnimation();
            }
        }
    }
      

  3.   

    楼上的代码是什么意思?
    我知道stateChanged是能触发的
      

  4.   

    需要addChangeListener
    ChangeListener接口中的方法就是
    stateChanged
      

  5.   

    我的意思是响应 mousePressed等一堆鼠标事件。