Results 1 to 3 of 3
  1. #1
    AWJustAGuy is offline Member
    Join Date
    Apr 2012
    Posts
    12
    Rep Power
    0

    Default Using MVC architecture... file input question for a Swing-based GUI.

    I'm trying to create a swing-based bank account program. I have the Account model, which contains the name, ID, and balance, as well as various get and set functions and conversions. I have the JFrame view, which contains a comboBox filled with the selectable accounts, and upon selecting one, it displays an editable field. I have the Controller, which runs the view and model and the actionListeners.

    I'm inputting my accounts from a file. To do this, I basically make an array of Account[] and fill in their name, id, balances for each account. My question is, do I put this code in the Model, or the controller? Either way it has to be passed to the view so that it can display the accounts, but I'm not sure where to stick it.

    Thanks!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default Re: Using MVC architecture... file input question for a Swing-based GUI.

    Data belongs in the model. The model doesn't pass the data to the view; the view queries the data from the model. There's a subtle difference.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Using MVC architecture... file input question for a Swing-based GUI.

    Quote Originally Posted by AWJustAGuy View Post
    I'm trying to create a swing-based bank account program. ...
    Quote Originally Posted by DarrylBurke View Post
    Data belongs in the model. The model doesn't pass the data to the view; the view queries the data from the model. There's a subtle difference.
    Exactly, with the net effect that the model has no knowledge of the view -- which is as it should be -- you should be able to use the same model with multiple different views.

Similar Threads

  1. Using MVC architecture in a Swing GUI program?
    By AWJustAGuy in forum New To Java
    Replies: 2
    Last Post: 04-24-2012, 05:57 AM
  2. Replies: 0
    Last Post: 03-15-2011, 08:51 AM
  3. Question about architecture
    By sdmente in forum Advanced Java
    Replies: 7
    Last Post: 07-28-2010, 01:07 PM
  4. Reading data from csv file based on specific input
    By jaiminparikh in forum Advanced Java
    Replies: 14
    Last Post: 02-13-2009, 09:07 PM
  5. Java based Web Application architecture
    By AmmarKhalid in forum New To Java
    Replies: 1
    Last Post: 11-05-2008, 08:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •