• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling a button from utility file

 
gary davis
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a utility file named AntoniosUtilityFile
public String reverseThisString(String toReverse)
{
return new StringBuffer(toReverse).reverse().toString();
}
}
}
I want to be able to click on a button called reverse in my main class
and it will access the information in my utility file.
public class Memo
{
public void actionPerformed(ActionEvent e)
{
if (actionCommand.equals("Reverse"))
"do something here to acces AntoniosUtilityFile"
"which will reverse the text once the reverse "
"button is clicked."
 
S Rubia
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well gary,
all i understand is that u had a file named AntoniosUtility.java which has a method named reverseThisString and u want to call it from ur class in actionPerformed method ...
If this is right then it is simple in actionPerformed
1-- make an object of ur AntoniosUtility class object as
AntoniosUtility obj=new AntoniosUtility();
(if there is default constructor)
2-- by this object call the required method by the passing String u want to reverse,and store the result in another string or directly displaying it whatever u want
String result=obj.reverseThisString(String);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic