Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Event handler Question

  Asked By: Jeff    Date: Aug 02    Category: Java    Views: 671
  

I am facing a peculiar problem, hoping someone can shed some light on
it.

I am trying to use the class startSearch to handle the button click
action Event. All my GUI is in the GUIThread class. But when I try to
access the startSearch constructor it gives me an error that
constructor could not be found.

File: GUIThread.java
=====================
class GUIThread extends Thread {
...
bSearch = new JButton("SEARCH") ;
bSearch.addActionListener
(new startSearch(tf1.getText(),tf2.getText()) ;
}

File: startSearch.java
======================
class startSearch implements ActionListener {

public startSearch(String dir, String pattern) {
sDir = dir ;
sPattern = pattern ;
}

public void actionPerformed(ActionEvent e) {
....
}
}

When compiling GUIThread.java, the error I see is :

Error: unable to find constructor
startSearch(java.lang.String, java.lang.String) ;

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Maurice Hanson     Answered On: Aug 02

bSearch.addActionListener( this );

and the declar new objct of startSearch class  in
actionPeformed function.

 
Didn't find what you were looking for? Find more on Event handler Question Or get search suggestion and latest updates.




Tagged: