import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JOptionPane; import javax.swing.JTextField; public class ViewCreate extends View { private JTextField tName; private JTextField tBook; private JComboBox cb; public ViewCreate(Library m, ControllerCreate c) { super(m, c); // window this.setTitle("View Create"); this.setSize(300, 200); GridLayout layout = new GridLayout(4, 1); this.setLayout(layout); // text field tName = new JTextField(); add(tName); // text field tBook = new JTextField(); add(tBook); // box cb = new JComboBox(); cb.addItem("Lender"); cb.addItem("Borrower"); add(cb); // button JButton b = new JButton("Create"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String name = tName.getText(); String num = tBook.getText(); String result = c.create(name, num, cb.getSelectedIndex()); // check if (result != "") { JOptionPane.showMessageDialog(null, result); } } }); add(b); // final this.setVisible(true); } public void update() { } }