#navi(contents-page-name): No such page: ST

FrontPage

Terai Atsuhiro 2021-11-26 (金) 05:14:30

http://terai.s55.xrea.com/swing/wheel/screenshot.png

spinner.addMouseWheelListener(new MouseWheelListener(){
  public void mouseWheelMoved(MouseWheelEvent e){
    JSpinner source = (JSpinner)e.getSource();
    SpinnerNumberModel model = (SpinnerNumberModel)source.getModel();
    Integer oldValue = (Integer)source.getValue();
    int intValue = oldValue.intValue()
                  -e.getWheelRotation()*model.getStepSize().intValue();
    Integer newValue = new Integer(intValue);
    if(model.getMaximum().compareTo(newValue)>=0 &&
       model.getMinimum().compareTo(newValue)<=0){
      source.setValue(newValue);
    }
  }
});