這是我的代碼 - 當我嘗試運行該程序時,它不會打印/顯示到我的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