如何解决将Int值输入文本字段
在JavaFX中,我有一个名为“ randomIntegerField”的TextField,当我按下按钮时,我需要使用方法返回的整数值自动填充此JavaFX JavaFX文本字段。
这是返回int值的方法
private int randomNum(){
Random random = new Random();
int integerIntered = Integer.parseInt(numberField.getText());
return random.nextInt(integerIntered - 0 + 1) + 0;
}
这是按钮
bntGo.setText("Go");
bntGo.setonAction(e -> {
randomIntegerField = String.valueOf(randomNum()); // The error i get is String can not converted into TextField.
});
请帮助我
解决方法
例如,您需要设置public class Receipt {
public static void main(String[] args) {
int subTotal = 38 + 40 + 30;
double tax = .08 * subTotal;
double tip = .15 * subTotal;
double total = subTotal + tax + tip;
printAmount("Subtotal:",subTotal);
printAmount("Tax:",tax);
printAmount("Tip:",tip);
printAmount("Total:",total);
}
private static void printAmount(String label,double value) {
System.out.println(label);
System.out.println(value);
}
}
的{{3}}(我假设是randomIntegerField
)...
TextField
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。