App design to MVC pattern <p>The answer on this question <a href="http://stackoverflow.com/questions/18317679/swing-how-to-get-container-bind-to-jradiobutton">Swing: how to get container bind to JRadioButton?</a> made me think of MVC in a simple app design. I describe the general idea of an app and my thoughts on MVC pattern for this case.</p> <p><strong>Small app description</strong>:</p> <p>This app lets user to add simple records that consist of name and description. After pressing "add" button, they are added to the panel as two labels and radio button to let edit the record. User can save his list in a profile (serialize to xml, properties or somewhere else).</p> <p><strong>My thoughts on how to apply MVC here</strong>:</p> <p><em>Model</em></p> <ul> <li><p>Record with name and description fields</p></li> <li><p>Profile with serialization mechanism</p></li> </ul> <p><em>View</em></p> <ul> <li>Panel that contains multiple panels (records list) - one for each record (radio button + 2 labels for name and description data)</li> </ul> <p><em>Controller</em></p> <ul> <li><p>2 text boxes with labels and a button to add record</p></li> <li><p>button to edit a record</p></li> </ul> <p>At the moment there's no code samples (I'll provide them a little bit later). I don't want to hurry, I want to understand whether I go in a right MVC direction or something should be changed before implementation.</p> <p><strong>Updated</strong></p> <p>Code sample</p> <pre><code>*MainClass*: public class RecordsControl extends JFrame { private RecordsModel model; private RecordsController controller; private RecordsControlView view; public RecordsControl() { super("Records Control"); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); initMVC(); getContentPane().add(view); pack(); setMinimumSize(new Dimension(250, 500)); setLocationRelativeTo(null); setResizable(false); setVisible(true); } private void initMVC() { model = new RecordsModel(); view = new RecordsControlView(controller); controller = new RecordsController(model, view); } } *Model*: public class RecordsModel { //Record class has only two fields String::name and String::description private List&lt;Record&gt; RecordsList; public RecordsModel() { RecordsList = new ArrayList&lt;Record&gt;(); } public void addRecord(String name, String description) { RecordsList.add(new Record(name, description)); } public List&lt;Record&gt; getRecordsList() { return RecordsList; } } *View*: public class RecordsControlView extends JPanel { private final RecordsController controller; private JLabel nameLabel; private JLabel descrLabel; private JTextField nameField; private JTextField descrField; private JButton addButton; private JButton editButton; private JButton deleteButton; private JPanel recordsListPanel; public RecordsControlView(RecordsController controller) { super(); this.controller = controller; achievNameLabel = new JLabel("Name: "); achievDescrLabel = new JLabel("Description: "); achievNameField = new JTextField(15); achievDescrField = new JTextField(15); addButton = new JButton("Add"); initGUI(); initListeners(); } private void initListeners() { addButton.addActionListener(controller); } private void initGUI() { //Main Panel this.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); //name panel //...BoxLayout label + panel //description panel //...BoxLayout label + panel //Records list Panel //...Vertical BoxLayout //Add widgets to GridBagLayout //Name panel constraints.gridx = 0; constraints.gridy = 0; constraints.insets = new Insets(5, 5, 2, 2); add(namePanel, constraints); //Description Panel constraints.gridx = 0; constraints.gridy = 1; constraints.insets = new Insets(0, 5, 5, 2); add(descrPanel, constraints); //Add button constraints.gridx = 1; constraints.gridy = 0; constraints.gridheight = 2; constraints.gridwidth = 1; constraints.insets = new Insets(5, 0, 5, 5); constraints.fill = GridBagConstraints.VERTICAL; add(addButton, constraints); //Records List panel constraints.gridx = 0; constraints.gridy = 2; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.gridheight = GridBagConstraints.REMAINDER; constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(0, 5, 5, 5); add(recordsListPanel, constraints); } public JButton getAddButton() { return addButton; } public void addRecord(JPanel record) { recordsListPanel.add(record); } } public class RecordsView extends JPanel { private static ButtonGroup radioButtons = new ButtonGroup(); private JRadioButton radioButton; private JLabel name; private JLabel description; public RecordsView() { super(); radioButton = new JRadioButton(); name = new JLabel(); description = new JLabel(); initGUI(); } private void initGUI() { radioButtons.add(radioButton); setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; add(radioButton, constraints); constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 1.0; constraints.fill = GridBagConstraints.HORIZONTAL; add(name, constraints); constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1.0; constraints.fill = GridBagConstraints.HORIZONTAL; add(description, constraints); } *Controller*: public class RecordsController implements ActionListener{ private final RecordsModel model; private final RecordsControlView view; public RecordsController(RecordsModel model, RecordsControlView view) { this.model = model; this.view = view; } @Override public void actionPerformed(ActionEvent e) { if(e.getSource() == view.getAddButton()) { RecordsView record = new RecordsView(); view.add(record); view.updateUI(); } } } </code></pre>