final project q12 giveup
This commit is contained in:
52
finalproject/Question12/ViewMoreBook.java
Normal file
52
finalproject/Question12/ViewMoreBook.java
Normal file
@@ -0,0 +1,52 @@
|
||||
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() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user