PDA

View Full Version : TextField(java)




Alvinkiang
May 1, 2006, 09:43 PM
Does anyone knows how to set the text field to editable of non-editable according to what it read in the XML??
e.g if XML reads
<edit> True</edit>

for(int l=total;l<2*total1;l++)
{
text1=new JTextField(newString[l]);
text1.setBounds(newPos[l],newPos[l+1],100,30);
text1.setEditable(false);<--------------------------- can be set to true
text1.setText("123");
panel.add(text1);



therevolution
May 1, 2006, 10:43 PM
How are you reading in the XML?

Alvinkiang
May 2, 2006, 12:31 AM
How are you reading in the XML?


i read whether inside this line <edit></edit> is it true or false... and i want the textfield editable to go according to it...

any idea?

frood
May 2, 2006, 06:36 PM
When you're reading in the XML you could create an boolean array to store whether or not the textfields should be editable. Then when you loop through creating them read back the array values.

But your description wasn't very clear, so I'm not sure if this is what you want.

therevolution
May 2, 2006, 07:42 PM
So, if you have the value somewhere already...


boolean isTextFieldEditable;
// set isTextFieldEditable to the value you read in from the XML

text1.setEditable(isTextFieldEditable);