Skip to main content

Problem when initializing Label text or button text

No replies
cesear89
Offline
Joined: 2013-07-20
Points: 0

Hello,

I'm creating an application that generate two random numbers and a random operator (+ - / *) and 4 suggestions. The suggestions are in 4 buttons (3 random numbers and the correct answer)
My problem is :
when the generated number have two characters the label text will be two points as you can see in attached pictures

http://s17.postimg.org/c3effy9nz/Sans_titre_1.jpg

http://s18.postimg.org/sd2pprend/image.jpg
here is a part of my code i start with create labels
Code:

final Label firstNumber = new Label("3");
final Label secondNumber = new Label("3");
final Label operator = new Label("+");
Label equal = new Label("=");
final Label result = new Label("?");
randomOperations.addComponent(firstNumber);
randomOperations.addComponent(operator);
randomOperations.addComponent(secondNumber);
randomOperations.addComponent(equal);
randomOperations.addComponent(result);
Game.addComponent(BorderLayout.CENTER, randomOperations);

then i set the label text to random numbers and operator
Code:

firstNumber.setText(a + "");
secondNumber.setText(b + "");
operator.setText(operation + "");

please give me hint im new in Lwuit