javazerofill

zerofill method using java


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


Solution

  • 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.