-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormGenerator.java
More file actions
153 lines (131 loc) · 2.84 KB
/
FormGenerator.java
File metadata and controls
153 lines (131 loc) · 2.84 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package javaCMS;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class FormGenerator extends JPanel
{
HPanel[] components;
JButton[] buttons;
String[][] comIDandName;
String[][] butIDandName;
int indexL = 0;
int indexB = 0;
public FormGenerator()
{
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setPreferredSize(new Dimension(450, 150));
}
public FormGenerator(String[] names)
{
for(String name : names)
{
add(new LabelTextBox(name));
}
}
public FormGenerator(int hcNum, int jbNum)
{
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
setPreferredSize(new Dimension(450, 150));
components = new HPanel[hcNum];
buttons = new JButton[jbNum];
comIDandName = new String[hcNum][2];
butIDandName = new String[jbNum][2];
}
public void addLabelTextBox(String name)
{
LabelTextBox ltb = new LabelTextBox(name);
components[indexL] = ltb;
comIDandName[indexL][0] = "" + indexL;
comIDandName[indexL][1] = name;
indexL++;
add(ltb);
}
public void addLabelComboBox(String name)
{
LabelComboBox lcb = new LabelComboBox(name);
components[indexL] = lcb;
comIDandName[indexL][0] = "" + indexL;
comIDandName[indexL][1] = name;
indexL ++;
add(lcb);
}
public void addButton(String name)
{
JButton jb = new JButton(name);
buttons[indexB] = jb;
butIDandName[indexB][0] = "" + indexB;
butIDandName[indexB][1] = name;
indexB++;
add(jb);
}
public LabelTextBox getLTB(String componentName)
{
int index = 0;
for(HPanel hp : components)
{
if((comIDandName[index][1] == componentName))
{
return (LabelTextBox)hp;
}
index++;
}
return null;
}
public LabelComboBox getLCB(String componentName)
{
int index = 0;
for(HPanel hp : components)
{
if((comIDandName[index][1] == componentName))
{
return (LabelComboBox)hp;
}
index++;
}
return null;
}
public JButton getButton(String componentName)
{
int index = 0;
for(JButton jb : buttons)
{
if((butIDandName[index][1] == componentName))
{
return (JButton)jb;
}
index++;
}
return null;
}
public String getCompText(String componentName)
{
int index = 0;
for(HPanel hc : components)
{
if((comIDandName[index][1] == componentName))
{
return hc.getText();
}
index++;
}
return null;
}
public void setCompText(String componentName, String text)
{
int index = 0;
for(HPanel hc : components)
{
if((comIDandName[index][1] == componentName))
{
hc.setText(text);
break;
}
index++;
}
}
}