summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/EditPanel.java
blob: 19110f82c258ed144c24d7e8f37e81d1e19d2df7 (plain)
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
package net.wotonomy.test;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.text.JTextComponent;

import net.wotonomy.ui.swing.components.ButtonPanel;
import net.wotonomy.ui.swing.components.InfoPanel;
import net.wotonomy.ui.swing.components.RadioButtonPanel;

/**
 * A simple editor panel with a few textfields.
 */
public class EditPanel extends JPanel {
	public JTextComponent firstNameField;
	public JTextField middleNameField, lastNameField;
	public RadioButtonPanel yearRadioPanel;
	public InfoPanel infoPanel;
	public JList list;
	public ButtonPanel addPanel;

	public EditPanel() {
		this.setLayout(new BorderLayout());
		this.setBorder(new EmptyBorder(10, 10, 10, 10));

		infoPanel = new InfoPanel();

		// name fields
		firstNameField = new JTextField();
		infoPanel.addPair("First Name", firstNameField);
		middleNameField = new JTextField();
		infoPanel.addPair("Middle Name", middleNameField);
		lastNameField = new JTextField();
		infoPanel.addPair("Last Name", lastNameField);
		yearRadioPanel = new RadioButtonPanel();
		infoPanel.addPair("Year", yearRadioPanel);

		list = new JList();
		JPanel containerPanel = new JPanel();
		containerPanel.setLayout(new BorderLayout(0, 5));
		JScrollPane scrollPane = new JScrollPane(list);
		scrollPane.setPreferredSize(new java.awt.Dimension(100, 100));
		addPanel = new ButtonPanel(new String[] { "Add", "Remove" });
		addPanel.setAlignment(FlowLayout.CENTER);
		containerPanel.add(scrollPane, BorderLayout.CENTER);
		containerPanel.add(addPanel, BorderLayout.SOUTH);
		infoPanel.addRow("Children", containerPanel);

		this.add(infoPanel, BorderLayout.CENTER);
	}

}