-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFirstDisplayControl.java
More file actions
83 lines (64 loc) · 2.47 KB
/
FirstDisplayControl.java
File metadata and controls
83 lines (64 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//control welcome gui of server
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
import java.awt.EventQueue;
public class FirstDisplayControl extends Thread {
private static FirstDisplay gui_1;
public FirstDisplayControl() {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
gui_1 = new FirstDisplay();
gui_1.frame.setVisible(true);
// Action listner for change price button
gui_1.getchangePriceButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
changePrice();
}
});
// Action listner for show stock list button
gui_1.getshowListButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
listStock();
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
// change price by server
private void changePrice() {
new ChangePriceGUIControl();
}
// display the stock list
private void listStock() {
new ListStockControl();
}
// update the price of 8 items in the display
private void loop() {
while (true) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Logger.getLogger(FirstDisplayControl.class.getName()).log(Level.SEVERE, null, e);
}
DefaultTableModel table = (DefaultTableModel) gui_1.gettable().getModel();
ChangesInGui.setDisplayStockUnits(gui_1, table);
}
}
// update the log table to show offer variation
public static void addDetailsToTable(Offer addOffer) {
DefaultTableModel Tracktable = (DefaultTableModel) gui_1.gettrackTable().getModel();
ChangesInGui.updateTrackTable(addOffer, Tracktable);
}
public void run() {
loop();
}
}