-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButtons.java
110 lines (90 loc) · 3.64 KB
/
Buttons.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
import javax.swing.*;
import javax.swing.table.TableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
public class Buttons extends JPanel {
JButton new_b;
JButton simulation_b;
JButton random_b;
public Buttons() {
new_b = new JButton("New");
simulation_b = new JButton("Simulation");
random_b = new JButton("Random graph");
new_b.setMaximumSize(new Dimension(120,30));
new_b.addActionListener((ae) -> {
Graph.getInstance().newGraph();
GraphicsFrame frame = (GraphicsFrame) SwingUtilities.getWindowAncestor(this);
frame.repaint();
});
simulation_b.setMaximumSize(new Dimension(120,30));
simulation_b.addActionListener(new SimulationButtonActionListener());
random_b.setMaximumSize(new Dimension(120,30));
random_b.addActionListener((ae) -> {
Graph.getInstance().makeRandomGraph();
GraphicsFrame frame = (GraphicsFrame) SwingUtilities.getWindowAncestor(this);
frame.repaint();
});
this.add(new_b);
this.add(simulation_b);
this.add(random_b);
}
class SimulationButtonActionListener implements ActionListener {
int k;
public void actionPerformed(ActionEvent ae) {
//makeBlankScreen();
System.out.print("simulation");
JFrame j = new JFrame();
j.setTitle("Kezdocsucs");
j.setVisible(true);
j.setSize(300, 300);
j.setLocation(100, 200);
JPanel p = new JPanel();
p.setSize(300,300);
JTextField text = new JTextField("Melyik csucsbol induljon?");
text.setEditable(false);
JTextField answer = new JTextField("Kerlek ide ird be a szamot");
answer.setEditable(true);
String s;
JButton button = new JButton(new AbstractAction("Ok") {
@Override
public void actionPerformed(ActionEvent e) {
int i = Integer.parseInt(answer.getText());
k = i;
j.dispatchEvent(new WindowEvent(j, WindowEvent.WINDOW_CLOSING));
Node n = Graph.getInstance().makeStarter(k);
Logic.run(Graph.getInstance(), n);
TableFrame tf = new TableFrame();
}
});
j.add(p);
p.add(text);
p.add(answer);
p.add(button);
/* List nodes = (List) Graph.getInstance().getNodes();
JFrame tablaFrame = new JFrame();
tablaFrame.setTitle("Futasi eredmeny");
tablaFrame.setVisible(true);
tablaFrame.setSize(300, 300);
tablaFrame.setLocation(100, 200);
tablaFrame.setLayout(new BorderLayout());
JTable jt = new JTable((TableModel) nodes); //
tablaFrame.add(new JScrollPane(jt), BorderLayout.CENTER);
jt.setFillsViewportHeight(true); */
}
}
class NewButtonActionListener implements ActionListener {
public void actionPerformed(ActionEvent ae) {
System.out.print("new");
Graph.getInstance().newGraph();
}
}
class RandomButtonActionListener implements ActionListener {
public void actionPerformed(ActionEvent ae) {
//makeBlankScreen();
System.out.print("randoo");
Graph.getInstance().makeRandomGraph();
}
}
}