overwrite existing value of a textbox with null

Discussion in 'Java' started by shruti tiwari via JavaKB.com, Apr 2, 2005.

  1. hi
    i am filling up a table of jTextbox with values from a database.when there
    are matching records it displays the required value allright but the
    problem arises when the database returns no record for that textbox.in this
    case we want it to display no value n return null or "" but is still
    displays the last displayed value...code:

    public void createtable(){
    t=new JTextField[5][7];
    int j=0,k=0;
    //JOptionPane.showMessageDialog(null,"Testing123");
    for(i=0;i<5;i++){
    for(l=0;l<6;l++){

    t[l] =new JTextField();
    }
    }
    for(i=0;i<5;i++){
    l=0;
    //System.out.print(j);
    k=0;
    while(l<6){

    // System.out.print(j);
    t[l].setText(null);//to initialize textbox to null
    t[l].setPreferredSize(new java.awt.Dimension(80, 20));
    t[l].setEnabled(false);
    t[l].setBounds(160+k,180+j,80,20);
    getContentPane().add(t[l]);
    k=k+80;
    l++;
    }

    --
    Message posted via http://www.javakb.com
    shruti tiwari via JavaKB.com, Apr 2, 2005
    #1
    1. Advertising

  2. Your array is 5 by 7 while your loops iterate through a 5 by 6 array.
    David.Federman, Apr 3, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VisionSet
    Replies:
    1
    Views:
    4,161
    Adam Lipscombe
    Sep 2, 2003
  2. zalla rouge
    Replies:
    0
    Views:
    461
    zalla rouge
    Sep 2, 2003
  3. Replies:
    5
    Views:
    26,502
    Mike Schilling
    Mar 29, 2006
  4. ma740988
    Replies:
    1
    Views:
    467
    Kai-Uwe Bux
    Mar 6, 2006
  5. Andy
    Replies:
    5
    Views:
    565
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jun 12, 2007
Loading...

Share This Page