• Post Reply 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Entering data in many tabbed JPanels and saving once

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I hoping some can give me some suggestions for my swing applictions.
The main JFrame s split in two , on top is a JPanel with components such as JTextField ,JTextArea ,JButton etc .The bottom of the JFrame is a JTabbedPane with multiples JPanels ( i.e. all tabbed ) each with its own components.
The user may enter in data any order they wish i.e. click on any tab enter in any info. None of the tabbed JPanels have an option to save the data.The only way info can be saved is by clicking the JButton on the top JPanel (i.e. not tabbed ).My question is , what is the cleanest / best way to collect all the data that the user has enter into each tab Jpanel so that it can be saved?
thanks in advance
jim
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would create an array in each JPanel with all the data components you want to save, then implement a saveRecord() method in each JPanel, that gets called from a saveRecord() method in your JTabbedPane, that gets called from a top-level saveRecord() method.
You would also need to write a loadRecord() method to reconstitute the data. You can probably get by with using object serialization. I think you might want to de-couple the UI from the data, so that what you are saving is just the data from your UI widgets, and not, say, and entire JTextField object.
I would first start with a simple test of saving one field on a panel, and trying to load it back in on start-up, just so you can understand the basic concept. Then you can branch out and create a "save tree" for all your nested objects.

Good Luck!

Rob
 
reply
    Bookmark Topic Watch Topic
  • New Topic