public class Justified { public final static byte LEFT = 0; public final static byte RIGHT = 1; public static String justify(byte justification, int szerokosc, String tekst) { String ret = ""; int iter = 0; switch(justification) { case Justified.LEFT: ret += tekst; iter = szerokosc - ret.length(); for(int i = 0; i < iter; i++) { ret += " "; } break; case Justified.RIGHT: iter = szerokosc - tekst.length(); for(int i = 0; i < iter; i++) { ret += " "; } ret += tekst; break; } return ret; } }