Files
oop/finalproject/Question7/ViewSimple.java
2022-05-24 23:19:13 +08:00

37 lines
773 B
Java

/*
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
* Date: 2022-04-25
*/
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ViewSimple extends JFrame implements ModelListener {
private Library m;
private ControllerSimple c;
private JLabel label;
public ViewSimple(Library m, ControllerSimple c) {
this.m = m;
this.c = c;
// window
this.setTitle("View Simple");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(300, 200);
m.addListener(this);
// component
label = new JLabel("Total number of borrowed books: " + m.totalBorrowedBooks());
add(label);
// final
this.setVisible(true);
}
public void update() {
label.setText("Total number of borrowed books: " + m.totalBorrowedBooks());
}
}