public JButton createButton(final int index, String text) {
        JButton b = new JButton();
        b.setText(text);
        b.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                switch (index) {
                    case 0:
                        String thoughtName = thoughtInputField.getText();
                        String notes = notesInputField.getText();
                        if (!listModel.contains(thoughtName)) {
                            controller.addThought(thoughtName, notes);
                            listModel.addElement(thoughtName);
                            notesInputField.setText("Notes");
                            thoughtInputField.setText("Thought");
                        } else {
                            JOptionPane.showMessageDialog(null, "This thought already exists!");
                        }
                        break;

                    case 1:
                        controller.workThoughtOut(thoughtList.getSelectedIndex());
                        break;
                    case 2:
                        controller.removeThought(thoughtList.getSelectedIndex());
                        break;
                }
            }
        });
        if (index < 3 && index >= 0) {
            buttons[index] = b;
        }
        return b;
    }