i have a little missbehaviour in my program.
One of his methods should build an string and then return it to be displayed in an Java Swing GUI. In some parts of it, it needs to store a "line break" (i dont know the proper name) "/n".
But when i display this string in the gui it contains /n instead of jumping the line properly.
Its a little confusing but with the code i think you can figure it out:
public String draw(Robot robot, MapClass mapa) {
map = mapa.getMapa();
String mapBuffer = "";
for (int i = 0; i < mapa.getLinhas(); i++) {
for (int j = 0; j < mapa.getColunas(); j++) {
if ((i == robot.getPosX()) & (j == robot.getPosY())){
System.out.print(robot.convertToChar() + " ");
mapBuffer = mapBuffer + robot.convertToChar() + " ";
}
else{
System.out.print(map[i][j] + " ");
mapBuffer = mapBuffer + map[i][j] + " ";
}
}
mapBuffer = mapBuffer + "/n";
System.out.println();
}
return mapBuffer;
}
This string is shown in a swing textArea with:
textArea.append(drawer.draw(robot, map));
Thanks.