0

I have 5 JFrames in my application and I want the values from all 5 JFrames to be sent to a single JFrame. And it is a process where I have to go one frame to another and the value entered previously should not be lost and must be visible at the end of the process.

Easy example is,

  1. I key in my name in the first frame,
  2. then I key in my Address in the second frame,
  3. then my mobile number in the third frame

and so on till the last frame where I want my keyed in details in the previous forms to be in the final frame to display my data in JTextfields. Is this possible? Because if it is a single form, I know how to do it. But when it is multiple forms in this situation I am lost. Please help.

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
Darsshan
  • 896
  • 1
  • 11
  • 22

1 Answers1

1

This has nothing to do with Swing or JFrames and all to do with the general issue of getting information from one object into another. Yes it's possible -- give the classes that you wish to extract information from "getter" methods, and then call them when you want the information. If you want to gather this information in an event-dependent fashion, then you will need to have one class listening for state changes brought on by events in the other classes. A PropertyChangeListener can work well for this.

Or if you use modal JDialog windows instead of JFrames, you will always be notified when the dialog has returned and is no longer visible, since the calling code's program flow resumes from right after where it told the dialog to become visible.

Next we can discuss whether having 5 separate JFrames is a good idea or not. I'm guessing you know my opinion on this, else I wouldn't have mentioned the subject.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • @Tyson: references for what? For writing getter and setter methods -- I'm sure that you're familiar with writing these. A tutorial for doing what you're specifically asking to do? That likely doesn't exist as you will need to break down your problem into its constituent small steps first, and then look for tutorials for those steps. Also I suggest that you search this site as similar questions have been answered, with code examples, some written by me. – Hovercraft Full Of Eels May 19 '13 at 18:34
  • @Tyson: for example please look at [this answer](http://stackoverflow.com/a/15044137/522444). – Hovercraft Full Of Eels May 19 '13 at 18:35