• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing component design question

 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a swing JPanel with data that will be updated every few minutes. The data will either contain by request from a server, or will be received via
a message. My question is where should the code be that either requests new data or receives the message? Should I utilize a separate controller the handles that. Then the controller sends the data to the JPanel that is
displaying it?

Thanks.
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

I suggest a model interface for the data. Implementations talk to the view either with an explicit use of an Observer pattern or with the implicit bounds provided by the Swing model classes (like TableModel implementations, Document, ...). The two different ways of updating that model should be represented by two distinct components.

Kai
 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about 2 separate TableModels?
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

no - two controllers.

Kai
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!