这是我的代码 - 当我尝试运行该程序时,它不会打印/显示到我的GUI中的finalResult
文本字段。有任何想法吗?为什么我的程序不能打印到我的GUI?
private void calculateButtonActionPerformed(java.awt.event.ActionEvent evt) {
// Coding:
int a = 1;
userInput = minInput.getText();
int value1 = Integer.parseInt(userInput);
userInput2 = maxInput.getText();
int value2 = Integer.parseInt(userInput2);
while (a <= value1)
{
//Print numbers inbetween user's value and 1:
int square = value1*value1;
//Print:
finalResult.setText("" + square);
//Modifier:
value1 = value1 + 1;
}
for (a = 0; a <= value1; a ++)
{
finalResult.setText("" + a*a);
}
while (value1 < value2)
{
//Print numbers inbetween value 2 and valeu1:
int square = value2*value2;
//Print:
finalResult.setText("" + square);
//Modifier:
value2 = value2 + 1;
}
for (a = 0; a <= value2; a ++)
{
finalResult.setText("" + a*a);
}
只是为了确保,要添加监听器的按钮吗? – DeadChex
好吧我会在这里听起来像一个白痴,并问你一个可能愚蠢的问题:通过听众你是指像Integer.parseInt或其他(我的课程是不是很丰富)编辑:我研究了它位,你的意思是像ActionListener – user3561829