Complete UpButt.

workbranch
asdfasdf 6 years ago
parent f476d1e3cb
commit 7ab1b38684

@ -14,12 +14,17 @@ public class StockEntry {
this.stype = stype;
}
public void update() {
public boolean update() {
boolean changed = false;
updating = true;
double[] result = this.stype.update(this.identifier);
if ((result[0] != price) || (result[1] != change)) {
changed = true;
}
this.price = result[0];
this.change = result[1];
updating = false;
return changed;
}
public String getTypeName() {

@ -133,13 +133,19 @@ public class WatchList extends Observable implements Load,Save {
public void updateList() {
Iterator watchit = iterator();
boolean changed = false;
while (watchit.hasNext()) {
Map.Entry entry = (Map.Entry)watchit.next();
StockEntry sentry = (StockEntry)entry.getValue();
if (!changed) {
changed = changed || sentry.update();
}
sentry.update();
}
setChanged();
notifyObservers(new Wevent(Etype.UPDATE));
if (changed) {
setChanged();
notifyObservers(new Wevent(Etype.UPDATE));
}
}
public class Wevent {

@ -11,12 +11,17 @@ public class UpButt extends JButton {
public UpButt(WatchList wlist) {
super("Update");
addActionListener(new UpButtList());
this.wlist = wlist;
this.wlist = wlist;
}
private class UpButtList implements ActionListener {
public void actionPerformed(ActionEvent e) {
//XXX Update WatchList
new Thread(new Runnable() {
@Override
public void run() {
wlist.updateList();
}
}).start();
}
}
}

Loading…
Cancel
Save