我想在窗口中显示一个变化的整数,但我无法弄明白。
我尝试使用命令
XPage.setText("Output: " + Integer.toString(x));
(XPage
是标签而x
是更改int
),但是在完成更改之前,此命令不会显示整数。
有谁知道如何显示整数?
编辑:我的代码,它使你插入的任何#转到50。
public void actionPerformed(ActionEvent event)
{
//String converted to an int
String input = textfield.getText();
int x = Integer.parseInt(input);
//int turned to 50
while (x<50||x>50) {
//Sleep
try{
Thread.sleep(250);
}
catch(InterruptedException ie){
//Log message if required.
}
XPage.setText("Output: " + Integer.toString(x));
System.out.println("Output: "+x);
if (x<50) {
x++;
}
if (x>50) {
x--;
}
}
System.out.println("Output: "+x);
XPage.setText("Output: " + Integer.toString(x));
}