-1

I want my textfield become like this “99999”

this is my code

while (rs.next()){
    int s=rs.getInt("Number");
    String num1 = String.valueOf(s);
    String n = String.format("%05d",num1);
    view.txtcustomernumber.setText(n);
}

why my txtcustomernumber(JTextField) always blank

Ruchira Gayan Ranaweera
  • 34,993
  • 17
  • 75
  • 115
Yuuki Rito
  • 17
  • 5
  • Have you tried printing out some debug statements? For example, what is the value of `s`? Or `num1`? Or of `n`? If you do this you could probably trace back the cause. Maybe a bug means this part of the code is never even executed! – devrobf Aug 16 '13 at 10:48
  • sorry typo i already remove the C – Yuuki Rito Aug 16 '13 at 10:50
  • i already try debug statement its nothing at bug statement but still blank – Yuuki Rito Aug 16 '13 at 10:54
  • @YuukiRito What is blank? The `int` variables can't be blank, tell us where it goes wrong. Is the value of `s` correct? – devrobf Aug 16 '13 at 10:55

1 Answers1

1

Try this.

while (rs.next()){
int s=rs.getInt("Number");
String n = String.format("%05d",s);
view.txtcustomernumber.setText(n);
}

It might solve your problem.

Vimal Bera
  • 10,346
  • 4
  • 25
  • 47
  • That's a good point - I'm pretty sure OP's code should generate an exception at runtime actually due to the `String` being placed in a `%d` field, which he hasn't mentioned... – devrobf Aug 16 '13 at 10:56
  • yea @jazzbassrob, that's the reason i skipped that line and it works perfectly fine. :) – Vimal Bera Aug 16 '13 at 11:00