File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling a method and changing it

 
Nick de Waal
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a method that clears all text fields of a particular GUI
here it is:

simple I know but I am a beginner and I thought I would write this to save me from writing it in different actionPerformed methods where I need the same result,
so I could just call this one.
Now for my question: Is it possible to call this method and somehow manipulate it to clear all text except for the first two?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on your specific needs, both now and what you might need in the future, some options are:

1) Pass a boolean indicating whether to clear those first 2 fields or not. The code to clear them goes in an if statement that checks that boolean.

2) Pass in an explicit list of names of fields to clear. (Or not to clear, if that's smaller/rarer.)

3) Break this method into two methods. One to clear all but the first 2, and the other that clears the first 2 fields and then calls the other method.

And various variations on the above.
 
Nick de Waal
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jeff,

I chose the 3rd option as I found it placed the least exertion on my brain
but I have copied the other 2 options to try out when I have a little more time.

And it works well for what I need.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic