import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JOptionPane; import javax.swing.JTextField; public class ViewGetBook extends View { private JTextField t; public ViewGetBook(Library m, ControllerGetBook c) { super(m, c); // win this.setTitle("View GetBook"); this.setSize(300, 200); GridLayout layout = new GridLayout(2, 1); this.setLayout(layout); t = new JTextField(); add(t); JButton b = new JButton("Tell me the book number"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String result = c.getBook(t.getText()); JOptionPane.showMessageDialog(null, result); } }); add(b); // final this.setVisible(true); } public void update() { // do nothing } }