无法将ChangeListener添加到JSpinner

时间:2014-06-13 07:12:20

标签: java swing compiler-errors actionlistener jspinner

这可能是一个非常简单的问题,但我有一个AbstractTable,在我的一个专栏中,我试图添加一个ChangeListener,但它给出了一个错误,错误是:

The method actionListener(ChangeListener) in the type JSpinner is not applicable 
    for the arguments (new ChangeListener(){})

以下是我的代码,我尝试在列中添加JSpinner

}else if (col == 4){
Date today = new Date();        //Creates new default date (Todays Date)
final JSpinner Spinner = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); // Creates Date Spinner
Spinner.addChangeListener(new ChangeListener() {     //Error Here 
      @Override
      public void stateChanged(ChangeEvent e) {
        // handle click
      }
    });
value = Spinner;

1 个答案:

答案 0 :(得分:2)

我猜您导入了错误的ChnageListener,您必须导入javax.swing.event.ChangeListener