final project q10
This commit is contained in:
40
finalproject/Question10/ViewGetBook.java
Normal file
40
finalproject/Question10/ViewGetBook.java
Normal file
@@ -0,0 +1,40 @@
|
||||
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<ControllerGetBook> {
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user