61 lines
1.2 KiB
Java
61 lines
1.2 KiB
Java
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<ControllerCreate> {
|
|
private JTextField tName;
|
|
private JTextField tBook;
|
|
private JComboBox<String> 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<String>();
|
|
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() {
|
|
}
|
|
}
|