e793. 监听JSpinner数据变化

 // Create a nummber spinner
    JSpinner spinner = new JSpinner();
    
    // Add the listener
    spinner.addChangeListener(new SpinnerListener());
    
    // Changing the value programmatically also fires an event
    spinner.setValue(new Integer(100));
    
    public class SpinnerListener implements ChangeListener {
        public void stateChanged(ChangeEvent evt) {
            JSpinner spinner = (JSpinner)evt.getSource();
    
            // Get the new value
            Object value = spinner.getValue();
        }
    }

 

Related Examples
posted @ 2018-09-06 09:08  borter  阅读(752)  评论(0编辑  收藏  举报