Hi,
I'm new to Java gui and don't know how to fix this problem. The
problem is that jLabel18 only display on the last line. Based on the
code, it should be on every line. Thank you for your time.
Regards,
Henry
for ( int i=0; i<systemValues.size(); i++ )
{
String sval = (String)systemValues.get(i);
if (sval.length() > 0)
{
try
{
for ( int ii=0; ii<reqValues.size(); ii++ )
{
if ( typedata == DataTypeConstants.dtSingleList)
{
Vector vvalues = getValuesVector(rval);
JComboBox xx = new JComboBox(vvalues);
panel2.add(new JLabel(l), new GridBagConstraints(0,
start,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE, new
Insets(5, 5, 0, 0), 26, 1));
panel2.add(xx, new GridBagConstraints(1, start, 1, 1,
0.0,0.0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,
5, 0, 0), 26, 1));
panel2.add(jLabel18, new GridBagConstraints(2, start, 1,
1,0.0,0.0,GridBagConstraints.WEST, GridBagConstraints.NONE, new
Insets(5, 5, 0, 0), 26, 1));
start++;
}
else
{
JTextField xx = new JTextField();
textToSave.add(xx);
textToSaveID.add(String.valueOf(rval));
String l = getAttributeName(rval);
panel2.add(new JLabel(l), new GridBagConstraints(0, start,1,
1,0.0,0.0,GridBagConstraints.WEST, GridBagConstraints.NONE, new
Insets(5, 5, 0, 0), 26, 1));
panel2.add(xx, new GridBagConstraints(1, start, 1, 1,
0.0,0.0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,
5, 0, 0), 26, 1));
panel2.add(jLabel18, new GridBagConstraints(2, start, 1, 1, 0.0,
0.0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5,
0, 0), 26, 1));
}
start++;
}
}
}
}
John McGrath - 16 Feb 2005 06:47 GMT
> The problem is that jLabel18 only display on the last line. Based
> on the code, it should be on every line.
A component cannot be added to the GUI multiple times. You will need to
create a new instance for each placement.

Signature
Regards,
John McGrath
dragonriver@gmail.com - 22 Feb 2005 23:31 GMT
I applied your suggestion and it works. Thank you for your help.
Regards,
Henry