java - Making Strings have equal lenght -


i want add texts in jlist , align doesn't work . doesnt align . let's have 2 strings : string = "apple juice good"; string b = "fun"; after using code string b still shorter

while(isok){     string string = string.format("%-100s",text);      // here adding strings jlist     menumodel.add(menulist.getmodel().getsize(), string + "l");  }    

you need use monospaced font rendering of text:

list.setfont( new font("monospaced", font.plain, 12) ); 

Comments