TextField(java)

Discussion in 'Mac Programming' started by Alvinkiang, May 1, 2006.

  1. macrumors newbie

    Joined:
    Apr 24, 2006
    #1
    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);
     
  2. macrumors 6502

    Joined:
    May 12, 2003
  3. thread starter macrumors newbie

    Joined:
    Apr 24, 2006
    #3

    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?
     
  4. macrumors newbie

    frood

    Joined:
    Nov 13, 2003
    Location:
    earth
    #4
    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.
     
  5. macrumors 6502

    Joined:
    May 12, 2003
    #5
    So, if you have the value somewhere already...

    Code:
    boolean isTextFieldEditable;
    // set isTextFieldEditable to the value you read in from the XML
    
    text1.setEditable(isTextFieldEditable);
    
     

Share This Page