-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFirstDisplay.java
161 lines (145 loc) · 5.66 KB
/
FirstDisplay.java
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//welcome display of the server
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
public class FirstDisplay {
public JFrame frame;
private JTable table;
private JScrollPane scrollPane;
private JButton showListButton;
private JButton changePriceButton;
private JTable trackTable;
private JLabel trackTableTitle;
private JScrollPane scrollPane_1;
public FirstDisplay() {
initialize();
}
@SuppressWarnings("serial")
private void initialize() {
frame = new JFrame();
frame.getContentPane().setBackground(new Color(0, 0, 51));
frame.setBackground(Color.WHITE);
frame.setAutoRequestFocus(false);
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1000, 2000);
frame.setResizable(false);
frame.getContentPane().setLayout(null);
scrollPane = new JScrollPane();
scrollPane.setBounds(35, 89, 582, 154);
frame.getContentPane().add(scrollPane);
//display 8 stock items in a table. table is not editable and resizable
table = new JTable();
table.setForeground(new Color(0, 51, 102));
scrollPane.setViewportView(table);
table.setFont(new Font("Tahoma", Font.BOLD, 15));
table.setModel(new DefaultTableModel(
new Object[][] {
{"FB",StockDB.getStockUnit("FB").getSecurityName(),null},
{"VRTU",StockDB.getStockUnit("VRTU").getSecurityName(),null},
{"MSFT",StockDB.getStockUnit("MSFT").getSecurityName(),null},
{"GOOGL",StockDB.getStockUnit("GOOGL").getSecurityName(),null},
{"YHOO",StockDB.getStockUnit("YHOO").getSecurityName(),null},
{"XLNX",StockDB.getStockUnit("XLNX").getSecurityName(),null},
{"TSLA",StockDB.getStockUnit("TSLA").getSecurityName(),null},
{"TXN",StockDB.getStockUnit("TXN").getSecurityName(),null}
},
new String[] {
"Symbol", "Security Name", "Price"
}
) {
Class[] columnTypes = new Class[] {
String.class, Object.class, String.class
};
public Class getColumnClass(int columnIndex) {
return columnTypes[columnIndex];
}
boolean[] columnEditables = new boolean[] {
false, false, false
};
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
});
table.getColumnModel().getColumn(0).setResizable(false);
table.getColumnModel().getColumn(0).setPreferredWidth(200);
table.getColumnModel().getColumn(1).setResizable(false);
table.getColumnModel().getColumn(1).setPreferredWidth(1000);
table.getColumnModel().getColumn(2).setResizable(false);
table.getColumnModel().getColumn(2).setPreferredWidth(100);
JLabel titleLabel = new JLabel("Welcome To StockExchange");
titleLabel.setForeground(new Color(204, 204, 153));
titleLabel.setFont(new Font("Sylfaen", Font.PLAIN, 40));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setBounds(149, 24, 657, 54);
frame.getContentPane().add(titleLabel);
showListButton = new JButton(" Show The List Of Stock Items");
showListButton.setFont(new Font("SansSerif", Font.PLAIN, 17));
showListButton.setBounds(666, 89, 290, 48);
frame.getContentPane().add(showListButton);
changePriceButton = new JButton("Change Current Price");
changePriceButton.setFont(new Font("SansSerif", Font.PLAIN, 17));
changePriceButton.setBounds(666, 195, 290, 48);
frame.getContentPane().add(changePriceButton);
scrollPane_1 = new JScrollPane();
scrollPane_1.setBounds(35, 347, 921, 292);
frame.getContentPane().add(scrollPane_1);
//table to show offer variation.table is not editable and resizable
trackTable = new JTable();
trackTable.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"Client Name", "Symbol", "Date", "Time", "Price"
}
) {
Class[] columnTypes = new Class[] {
String.class, String.class, String.class, String.class, String.class
};
public Class getColumnClass(int columnIndex) {
return columnTypes[columnIndex];
}
boolean[] columnEditables = new boolean[] {
false, false, false, false, false
};
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
});
trackTable.getColumnModel().getColumn(0).setResizable(false);
trackTable.getColumnModel().getColumn(0).setPreferredWidth(800);
trackTable.getColumnModel().getColumn(1).setResizable(false);
trackTable.getColumnModel().getColumn(1).setPreferredWidth(200);
trackTable.getColumnModel().getColumn(2).setResizable(false);
trackTable.getColumnModel().getColumn(2).setPreferredWidth(400);
trackTable.getColumnModel().getColumn(3).setResizable(false);
trackTable.getColumnModel().getColumn(3).setPreferredWidth(400);
trackTable.getColumnModel().getColumn(4).setResizable(false);
trackTable.getColumnModel().getColumn(4).setPreferredWidth(200);
scrollPane_1.setViewportView(trackTable);
trackTableTitle = new JLabel("Offers varied with time");
trackTableTitle.setForeground(new Color(204, 204, 153));
trackTableTitle.setFont(new Font("Tahoma", Font.PLAIN, 20));
trackTableTitle.setBounds(63, 304, 845, 32);
frame.getContentPane().add(trackTableTitle);
}
//return buttons and tables
public JButton getchangePriceButton () {
return changePriceButton ;
}
public JButton getshowListButton() {
return showListButton;
}
public JTable gettable() {
return table;
}
public JTable gettrackTable() {
return trackTable;
}
}