Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing architecture issues, what would you do?

 
Vandre Caetano
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

The think is: I am trying to make sense of java Swing achitecture.
At first I was daydreaming of a Swing architecture where I would have a Model, with some sort of Data Object and a save method. In my humble head it sounded simple...
So I started reading and found the following article: http://java.sun.com/products/jfc/tsc/articles/architecture/
which talks about Swing separable model architecture using some interfaces like the Document one, and after reading it and trying things on my omw I am far far more lost than when I first started

Consider the following cenario:

1 JPanel with 4 JTextField and a save button

So.. acording to sun, it would need take 4 Documents (one for each field) and 1 ButtonModel(for the button) with some small among of the logic in each of then and.. hum.. In the end it seens... well... overcomplicated so I decided to try something else which got me right back and the lost status.

How would you do a swing architecture where in the end you would have a Model with some sort of Data Object and a save method?
Would you not use Suns Documente/Other models interface? would you override all JComponets with some personal implementation? Is there any page you advice me to read?


Thanks in Advance
 
Oliver Watkins
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It only needs to be as complicated as it needs to be. What would you have a Document for each textfield? You should only worry about the complexities of the Swing architecture when you get to tables and trees.

Just use setText and getText on the text fields, and add an action listener to the button. Done.

Olly [url removed]


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic