• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling a button from utility file

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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."
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
reply
    Bookmark Topic Watch Topic
  • New Topic