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 all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

filing an array with the output from a method  RSS feed

Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Report post to moderator

I've written an actionPerformed method for a basic swing program. This program takes input from a text field and then converts it for the required result. Therefore, there are two doubles produced.

Basically, how would I then add those two results to an array so I could call them from two other buttons?

I'm having real problems linking an array to an actionPerformed method. My current actionPerformed method is as follows,

I really can't seem to see the wood for the trees with this one. Any help appreciated!
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Report post to moderator
First of I would use an ArrayList instead of an array since it is more or less dynamically resized. If you want your ArrayList to be seen everywhere else in your class you should declare is as an instance variable. I can't tell from what ou have posted whether you are using a seperate concrete class to implement your ActionListener or an anonymous inner class, so its kind of hard to tell you exactly how to do it. If you are using an anonymous inner class I would do it like this.

Hope I helped a little.


[edited because I'm lost without a spellchecker ]
[ January 28, 2006: Message edited by: Garrett Rowe ]
author and iconoclast
Posts: 24220
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please don't post the same question in multiple forums. This topic in JiG Beginner already has some replies, too -- I'm closing this thread.
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!