我需要一些帮助gettext一个整数然后在我从用户添加的整数中得到整数后,我需要添加10来感谢下面的代码的帮助; \
private void btnCalculateMouseClicked(java.awt.event.MouseEvent evt)
{
Integer memoryAdd1, total, radBlue1, radWhite1, radBlack1, microsoftYes1,
caseA1, batteryA1, webcamA1, windows20001, windowsVista1;
radBlack1 = 0;
radWhite1 = 0;
radBlue1 = 0;
microsoftYes1 = 0;
caseA1 = 0;
batteryA1 = 0;
webcamA1 = 0;
windows20001 = 0;
windowsVista1 = 0;
memoryAdd1 = 0;
if (radBlack.isSelected()) { radBlack1 = radBlack1 + 5; };
if (radWhite.isSelected()) { radWhite1 = radWhite1 + 5; };
if (radBlue.isSelected()) { radWhite1 = radWhite1 + 10; };
memoryAdd.getText(Integer.toString( memoryAdd1 = memoryAdd1+10));
if (microsoftYes.isSelected()) { microsoftYes1 = microsoftYes1 + 100; };
if (caseA.isSelected()) { caseA1 = caseA1 + 50; };
if (batteryA.isSelected()) { batteryA1 = batteryA1 + 30; };
if (webcamA.isSelected()) { webcamA1 = webcamA1 + 25; };
if (windows2000.isSelected()) { windows20001 = windows20001 + 300; };
if (windowsVista.isSelected()) { windowsVista1 = windowsVista1 + 300; };
total = radBlack1 + radWhite1 + radBlue1 + microsoftYes1 + caseA1 +
batteryA1 + webcamA1 + windows20001 + windowsVista1;
beforeTax.setText(Integer.toString(total));
}
答案 0 :(得分:2)
它看起来只是铸造问题..
MemoryAdd1+=10
String str = Integer.toString( memoryAdd1)
memoryAdd.getText(str);
顺便问一下你的记忆是什么?这是AWT文本框?你试图设定价值吗?
答案 1 :(得分:1)
你的问题是,一旦值在转换函数中,你就不能再用它做数学,因为它现在是一个字符串。
试试这个
MemoryAdd1+=10
memoryAdd.getText(Integer.toString( memoryAdd1));