• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to deal with form data while switching between multiple frames  RSS feed

 
Srinivasa Maddi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have created a swing application in netbeans environment. This app consists of four frames. Now my requirement is, after filling Form1 when user clicks "Next" button then form1's data should be buffered somewhere and then go to second form and so on. Finally when user lands in the last form, at this point i want the total data of all forms should be stored in database.

Thanks
Maddi
 
Rob Spoor
Sheriff
Posts: 21052
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds like some sort of wizard solution, and then using a java.awt.CardLayout is one of the best ideas.

You create the four different forms, then add each to a JPanel with a CardLayout. Pressing the Next button only switches the panel (use CardLayout.next for this).

Then, at the end, you have all forms and all of their controls still available - you only see the last form, the others are invisible.
 
Srinivasa Maddi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob, thank you for your response. Probably i can workout with this solution later becoz i had already done with most of the stuff without JPanel suggested by you. Rob, for the timebeing is there any other go for me?
 
Rob Spoor
Sheriff
Posts: 21052
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could store the results in an object, and pass this object around. Now you can create a custom object, with fields for all values you need, or a Map<String,Object> for ease.

For instance, when pressing Next upon some login form (the Map is called values):

When showing the next form, you pass along this object.

As you can see, the Map can only store Objects as its values (unless you only have text fields, in which case it can be Map<String,String>) . You will have to cast your values when retrieving them from the Map:


You won't need all this casting when creating a custom object:

However, when you want to add a field you need to change this class first.
[ September 29, 2008: Message edited by: Rob Prime ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!