-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabeledInput.java
More file actions
33 lines (27 loc) · 795 Bytes
/
LabeledInput.java
File metadata and controls
33 lines (27 loc) · 795 Bytes
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
package mandeljava;
import java.awt.Dimension;
import java.awt.Panel;
import java.awt.TextField;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
public class LabeledInput extends Panel {
private final JLabel label;
private final TextField input;
public LabeledInput(String labelText) {
this.label = new JLabel(labelText);
this.input = new TextField();
super.setLayout(null);
this.label.setHorizontalAlignment(SwingConstants.RIGHT);
this.label.setBounds(0, 0, 95, 20);
this.input.setBounds(100, 0, 150, 20);
super.setPreferredSize(new Dimension(250, 20));
super.add(label);
super.add(input);
}
public void setText(String text) {
this.input.setText(text);
}
public String getText() {
return this.input.getText();
}
}