-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMassPanel.java
More file actions
62 lines (54 loc) · 1.65 KB
/
MassPanel.java
File metadata and controls
62 lines (54 loc) · 1.65 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
package Extra;
import java.awt.*;
import javax.swing.*;
/**
*
* @author bryan_bancroft
*/
public class MassPanel extends JPanel{
protected JRadioButton ounces;
protected JRadioButton pounds;
protected JRadioButton grams;
protected JRadioButton kilograms;
protected ButtonGroup metricBtn;
protected ButtonGroup englishBtn;
protected JLabel metricLabel;
protected JLabel englishLabel;
protected JTextField english;
protected JTextField metric;
public MassPanel(){
ounces = new JRadioButton("Ounces");
pounds = new JRadioButton("Pounds");
grams = new JRadioButton("Grams");
kilograms = new JRadioButton("Kilograms");
english = new JTextField(20);
metric = new JTextField(20);
englishLabel = new JLabel("English");
metricLabel = new JLabel("Metric");
metricBtn = new ButtonGroup();
englishBtn = new ButtonGroup();
metricBtn.add(grams);
metricBtn.add(kilograms);
englishBtn.add(ounces);
englishBtn.add(pounds);
//Set Layout
setLayout(new GridLayout(8,1));
//Set Border
setBorder(BorderFactory.createTitledBorder("Mass"));
//Add Components
add(englishLabel);
add(ounces);
add(pounds);
add(english);
add(metricLabel);
add(grams);
add(kilograms);
add(metric);
}
public void ClearAll(){
englishBtn.clearSelection();
english.setText("");
metricBtn.clearSelection();
metric.setText("");
}
}