-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.java
More file actions
94 lines (77 loc) · 2.26 KB
/
Graph.java
File metadata and controls
94 lines (77 loc) · 2.26 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
84
85
86
87
88
89
90
91
92
93
94
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Root extends JFrame {
public MyTable table;
public Root() {
super("jgraphq1");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
build(getContentPane());
// display the windows
// pack();
setVisible(true);
getRootPane().
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).
put(KeyStroke.getKeyStroke("ESCAPE"), "quit");
getRootPane().getActionMap().put("quit", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
System.out.println("Bye Bye");
System.exit(0);
}
});
}
public void build(Container panel) {
panel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
GridBagConstraints _gbc = new GridBagConstraints();
// gbc_def
// _gbc.gridx=0; _gbc.gridy=0;
// _gbc.insets= new Insets(0, 0, 0, 0);
_gbc.gridwidth = 1; _gbc.gridheight = 1;
_gbc.weightx = 0; _gbc.weighty = 0;
_gbc.fill = GridBagConstraints.NONE;
_gbc.anchor = GridBagConstraints.FIRST_LINE_START;
gbc = _gbc;
JCheckBox join_pts = new JCheckBox("Join Points", true);
panel.add(join_pts, gbc);
JCheckBox pts_show = new JCheckBox("Show Point", true);
gbc.gridx = 1;
panel.add(pts_show, gbc);
JCheckBox pts_label = new JCheckBox("Point Label");
gbc.gridx = 2;
panel.add(pts_label, gbc);
table = new MyTable();
gbc.weightx = 1; gbc.weighty = 1;
gbc.gridx = 0; gbc.gridy = 1;
gbc.gridwidth = 4; gbc.gridheight = 1;
gbc.insets = new Insets(0, 0, 0, 0);
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.CENTER;
panel.add(table, gbc);
join_pts.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
table.canvas.join = !table.canvas.join;
repaint();
}
});
pts_show.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
table.canvas.point = !table.canvas.point;
repaint();
}
});
pts_label.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
table.canvas.label = !table.canvas.label;
repaint();
}
});
}
}
public class Graph {
public static void main(String[] args) {
Root root = new Root();
root.setSize(600, 462);
root.setLocation(350, 150);
}
}