Repository navigation
Expand file tree
/
Copy pathUI.java
More file actions
91 lines (69 loc) · 1.62 KB
/
Copy pathUI.java
File metadata and controls
91 lines (69 loc) · 1.62 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
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.LineBorder;
public class UI {
private JFrame frame;
private JPanel panel;
private JTable table;
public static void main(String[] args) {
new UI().montaJanela();
}
public void montaJanela(){
montaFrame();
montaPanel();
montaTable();
botaoCarregar();
exibirJanela();
}
private void montaFrame(){
frame = new JFrame(
"Nossa Aplicação");
frame.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
}
private void montaPanel(){
panel = new JPanel();
frame.add(panel);
}
private void exibirJanela(){
frame.pack();
frame.setSize(540, 540);
frame.setVisible(true);
}
private void botaoCarregar(){
JButton botao =
new JButton("Carregar XML");
botao.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(
ActionEvent e) {
List<Candle> candles =
new EscolheXML().escolher();
table.setModel(
new CandleTableModel(candles));
}
});
panel.add(botao);
}
private void montaTable(){
table = new JTable();
table.setBorder(
new LineBorder(Color.black));
table.setGridColor(Color.black);
table.setShowGrid(true);
JScrollPane scroll = new JScrollPane();
scroll.getViewport().setBorder(null);
scroll.getViewport().add(table);
scroll.getViewport()
.setSize(450, 450);
panel.add(scroll);
}
}