File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes What kind of error is this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What kind of error is this?" Watch "What kind of error is this?" New topic

What kind of error is this?

nani aman
Ranch Hand

Joined: Sep 22, 2004
Posts: 33
hi, its me again with a lot of blurr..
i had this error in my second class. It seem like lack of something but i couldn't figure it out. What actually i need to do?\

error :
addItemListener(java.awt.event.ItemListener) in javax.swing.AbstractButton cannot be applied to

i hope someone can show me the way..
Thank you.
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Maybe some code would help, but my guess is that you have not called the add method on an actual component (button?)


SCJP 1.4,
nani aman
Ranch Hand

Joined: Sep 22, 2004
Posts: 33
This is some codes that used addItemListener, this is not button but a check box. bFinish is the only button i use in here.


addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){

Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Are you sure your class is implementing the ItemListener interface?

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
nani aman
Ranch Hand

Joined: Sep 22, 2004
Posts: 33
i implemented the action listener in the class. I change qchk1Yes.addItemListener(this) to qchk1Yes.addActionListener but i still could get why they is error.
J Chandler
Ranch Hand

Joined: May 17, 2003
Posts: 32
Hi nani,

when we want to implement a Listener interface, we need to declare it
somewhere so the compiler knows.
That means either making our own listener class to handle all the methods
in the listener interface ...
OR, what would be best in this case, because ItemListener has only 1 method - itemStateChanged - we could simply state that we are implementing the ItemListener interface when declaring the class.


and don't forget to code your own itemStateChanged method in Class2 - if the compiler knows you want to use ItemListener, it will be looking for your implementation of this method.


hope that helps

[ October 19, 2004: Message edited by: J Chandler ]

[ October 19, 2004: Message edited by: J Chandler ]
[ October 19, 2004: Message edited by: J Chandler ]
I agree. Here's the link:
subject: What kind of error is this?