0

I have 2 forms in my program, one is basic application form which shows when app starts and second is form for adding entities to database. It works intuitively: in default form you click add button, second form shows, where you fill some text areas and click done button.

My question, how to pass data from second form to first one?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Miloš Lukačka
  • 842
  • 1
  • 11
  • 25
  • See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) 'Form 2' should be a modal `JDialog`. This comes up around every 8 hours on SO. – Andrew Thompson May 08 '13 at 11:15

1 Answers1

1
method 1 :
1 : create 1 form
2 : add all fields for entering fields and also the fields from the confirmation form
3 : hide the confirmation fields
4 : when user clicks submit , hide the fields of first form , show the fields of second form

thus you all the data in one form only and you can handle the data as you want

ohk then lets try this

create a form 1
create a form 2
create a bean class having all the fields from form 1
now create a simple main class calling form 1
when user submits the form 1 , take all the values from form1 , create an object of the bean , store the values in the bean object , thus you are still in the main class 
after setting the values in the bean , call the form 2 frame , and set the fields in form 2 by using the same object of the bean class