-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathNodeSettingsEditor.java
More file actions
55 lines (45 loc) · 1.61 KB
/
NodeSettingsEditor.java
File metadata and controls
55 lines (45 loc) · 1.61 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
package nodebox.client;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
public class NodeSettingsEditor extends JPanel implements ActionListener, FocusListener {
private NodeAttributesDialog dialog;
private JCheckBox exportBox;
public NodeSettingsEditor(NodeAttributesDialog dialog) {
this.dialog = dialog;
initPanel();
updateValues();
}
private void initPanel() {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
JPanel contentPanel = new JPanel();
contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
// Exported
exportBox = new JCheckBox("Exported (available to users of this library)");
exportBox.addActionListener(this);
contentPanel.add(exportBox);
contentPanel.add(Box.createVerticalGlue());
add(contentPanel);
}
public void updateValues() {
exportBox.setSelected(dialog.getNode().isExported());
revalidate();
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == exportBox) {
dialog.setNodeExported(exportBox.isSelected());
} else {
throw new AssertionError("Unknown source " + e.getSource());
}
updateValues();
}
public void focusGained(FocusEvent e) {
// Do nothing.
}
public void focusLost(FocusEvent e) {
actionPerformed(new ActionEvent(e.getSource(), 0, "focusLost"));
}
}