summaryrefslogtreecommitdiff
path: root/src/bjc/imgchain/utils/LabeledInputPanel.java
blob: 7eed8b029d776cd0781e11a39929b24fe8cb9338 (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
package bjc.imgchain.utils;

import java.awt.BorderLayout;

import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * A component for getting formatted input with a label.
 * 
 * @author bjculkin
 *
 */
public class LabeledInputPanel extends JPanel {
	private static final long serialVersionUID = 1031310890698539040L;

	/**
	 * The field input is stored in.
	 */
	public final JFormattedTextField field;

	/**
	 * Create a new labeled input component.
	 * 
	 * @param label
	 *            The label for the component.
	 * @param val
	 *            The initial value for the field.
	 */
	public LabeledInputPanel(String label, Object val) {
		super();
		setLayout(new BorderLayout());

		JLabel xLabel = new JLabel(label);

		field = new JFormattedTextField(val);

		add(xLabel, BorderLayout.LINE_START);
		add(field, BorderLayout.CENTER);
	}
}