• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can an interface inherits from AbstractButton?  RSS feed

 
Ilh Oleo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to implent an interface but netbeans says this "interface expected here".
What i want to do is extend the AbstractButton class to implement it into a ActionEvent to clear a jTextField in differents clases but i�m not sure about doing it


Is there an error??
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An interface can't extend a class, so yes, this is an error. I don't understand your description of what you're trying to do. Maybe you want to extend AbstractButton with a new class instead? Maybe an abstract one?
 
Ilh Oleo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to create a method to clear the typed info into a JTextField maybe because that is a wrong info or something else , so implement it on my class.
So if i make another graphic application (that i have been doing in class) just implement it instead of something like this

I�ve looking in the forum and books and i think it would be better to change it for a abstract class
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that you will need to use AbstractButton directly. Instead, create a JButton. Have your class that extends JFrame implement the ActionListener interface. Then, in your class that extends JFrame, implement a method called actionPerformed(ActionEvent). Define the method actionPerformed(ActionEvent) to call setText() to set the text of your JTextField to be the empty String.

If you have more than one button in your window, you can distinguish them by using the ActionEvent object that is passed as a parameter to actionPerformed(ActionEvent). For example, event.getObject() will return the object reference variable of the button that was pressed.

Kaydell
[ June 19, 2007: Message edited by: Kaydell Leavitt ]
 
Ilh Oleo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah i realized that after some extensive analysis .. thanks anyway
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!