Files
oop/finalproject/Question11/ViewMoreBook.java
2022-05-24 23:51:13 +08:00

53 lines
1.1 KiB
Java

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 ViewMoreBook extends View<ControllerMoreBook> {
private JTextField tName;
private JTextField tBook;
public ViewMoreBook(Library m, ControllerMoreBook c) {
super(m, c);
// window
this.setTitle("View More Book");
this.setSize(300, 200);
GridLayout layout = new GridLayout(3, 1);
this.setLayout(layout);
// text field 1
tName = new JTextField();
add(tName);
// text field 2
tBook = new JTextField();
add(tBook);
// button
JButton b = new JButton("Tell me the book number");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name = tName.getText();
String num = tBook.getText();
String result = c.moreBook(name, num);
// check
if (result != "") {
JOptionPane.showMessageDialog(null, result);
}
}
});
add(b);
// final
this.setVisible(true);
}
public void update() {
}
}