• Post Reply Bookmark Topic Watch Topic
  • New Topic

Events and Listeners - Im very confused!  RSS feed

 
Tom Hill
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay I think my question would be explained best with a simple example.
I have an Application.
The Application has a JFrame with 2 panels
The first panel has a JTextField and a JButton
The 2nd Panel has A large JTextField
I have created an Action object and I have assigned the Action to the button.
At a later date I may wish to add a menu to the Frame that has an item to do the same action.
What do i put in the actionPerformed method of my Action Object to add text from the 1st panel's text to the text field on the 2nd panel.
Im fairly sure I dont wish to use static methods.
Im assuming my application requires an actionlistener, that listens for my action fired by the button in the first panel.
Can anyone help or offer simplier alternatives!
Cheers
 
Tom Hill
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the probem comes because my panels are separate objects.
When the actionPerformed method is run i really want to go Application.dotheAddingTextMethod(). But i need to be able to find the instance of the application running. Is it possible to find the creator of an instance?
 
Tom Hill
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Ive solved it! cheers anyway!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad we could be your Cardboard Analyst.
Moving this to the Swing / JFC / AWT forum, where folks love to get all messy with this GUI stuff...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!