parent
5e92eae32f
commit
f476d1e3cb
@ -1,24 +0,0 @@
|
|||||||
package observer;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
public abstract class Subject {
|
|
||||||
protected ArrayList<Wobserver> obsList = new ArrayList<Wobserver>();
|
|
||||||
|
|
||||||
public void addObs(Wobserver obs) {
|
|
||||||
obsList.add(obs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delObs(Wobserver obs) {
|
|
||||||
//Collections.singleton from https://howtodoinjava.com/java/collections/arraylist/arraylist-removeall/
|
|
||||||
obsList.removeAll(Collections.singleton(obs));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMsg() {
|
|
||||||
for (Wobserver obs : obsList) {
|
|
||||||
obs.update(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
package observer;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import data.WatchList;
|
|
||||||
|
|
||||||
public interface Wobserver {
|
|
||||||
public void update(Subject obsed);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package ui.guicomp;
|
||||||
|
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.table.TableModel;
|
||||||
|
import data.WatchList;
|
||||||
|
|
||||||
|
//https://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html
|
||||||
|
public class WatchTablePane {
|
||||||
|
private JTable table;
|
||||||
|
private TableModel tmodel;
|
||||||
|
private JScrollPane spane;
|
||||||
|
|
||||||
|
public WatchTablePane(WatchList wlist) {
|
||||||
|
tmodel = new WatchTableModel(wlist);
|
||||||
|
table = new JTable(tmodel);
|
||||||
|
spane = new JScrollPane(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JScrollPane getPane() {
|
||||||
|
return spane;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue