2012-11-30 34 views
0

這是無效的嗎?在JLabel擴展類中找不到符號

public class LayerItem extends JLabel{ 
    public LayerItem(){ 
     this.addActionListener(new java.awt.event.ActionListener(){ 
      @Override 
      public void actionPerformed(java.awt.event.ActionEvent evt){ 

      } 
     }); 
    } 
} 

我得到第3行的錯誤說:cannot find symbol: method addActionListener(<anonymous ActionListener>)

回答

4

方法addActionListener不適用於JLabel組件。

+0

哇,我現在覺得自己像個白癡。謝謝,我想'addMouseListener' –