我有一小段代码,它应该取余数值并分配给另一个对象。
private void showOnesSecsActionPerformed(java.awt.event.ActionEvent evt) {
int secs = Integer.parseInt(oneSecs.getText()); //Grabs the value of the oneSecs JTextfield
String lctn = "images\\" + secs + ".png"; //Looks for the image that corresponds with the number and has an extension of .png
oneSecsDisplay.setIcon(new ImageIcon (lctn));//Uses the lctn to assign the corresponding image to the oneSecsDisplay button
while (secs > 9){
secSecsDisplay.setIcon(new ImageIcon ("images\\" + secs/10 + ".png"));
}
}
我不确定我是否正确这样做,我知道 oneSecsDisplay 只会显示0到9之间的数字值(工作正常)
然而当它达到10;它应该提示下一个显示, secSecsDisplay 以显示十进制值。即14 - > secSecsDisplay显示1 , oneSecsDisplay显示4