-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountForm.java
More file actions
57 lines (45 loc) · 1.76 KB
/
CountForm.java
File metadata and controls
57 lines (45 loc) · 1.76 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
package Room_Planner;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import java.util.LinkedList;
public class CountForm extends JFrame implements ActionListener {
LinkedList<FurnitureData> furnitureList = new LinkedList<FurnitureData>();
JButton btnExit;
SpringLayout myLayout = new SpringLayout();
JTextField[][] textFields;
JLabel lblItems, lblCount;
public CountForm(LinkedList<FurnitureData> data) {
furnitureList = data;
Collections.sort(furnitureList);
setSize(300, (furnitureList.size() * 30) + 100);
setLayout(myLayout);
setLocation(300, 100);
lblItems = UIBuilder.CreateALabel("Item", 63, 10, myLayout, this);
lblCount= UIBuilder.CreateALabel("Count", 160, 10, myLayout, this);
btnExit = UIBuilder.CreateAButton("Exit", 80, 25, 125, furnitureList.size() * 25 + 40, this, myLayout, this);
BuildTextFields();
setVisible(true);
}
private void BuildTextFields()
{
textFields = new JTextField[furnitureList.size()][2];
for (int i = 0; i < furnitureList.size(); i++)
{
int yPos = 40 + i * 25;
textFields[i][0] = UIBuilder.CreateATextField(7, 40, yPos, myLayout, this);
textFields[i][1] = UIBuilder.CreateATextField(7, 140, yPos, myLayout, this);
textFields[i][0].setText(furnitureList.get(i).getFurniture());
textFields[i][1].setText(furnitureList.get(i).getCount() + "");
}
}
@Override
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == btnExit)
{
this.dispose();
}
}
}