首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

大伙儿知道Slider这个组件吗?这个组件能触发鼠标事件吗

2011-12-02 
大家知道Slider这个组件吗?这个组件能触发鼠标事件吗?有时郁闷就是不知道这个组件有哪些对应触发事件可以

大家知道Slider这个组件吗?这个组件能触发鼠标事件吗?
有时郁闷就是不知道这个组件有哪些对应触发事件可以调用。

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


[解决办法]

Java code
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 marks.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();        }    }}
[解决办法]
需要addChangeListener
ChangeListener接口中的方法就是
stateChanged

热点排行