[英]JSpinner doesn't show
我真的不明白JSpinner发生了什么。 我实例化了它,然后尝试使用setBounds在JPanel上设置它,但我唯一得到的是:
中间的小方块应该是我的JSpinner。
我的代码是这样的:
private JSpinner spinnerDayBirth;
spinnerDayBirth = new JSpinner();
spinnerDayBirth.setBounds(280,351, 25, 25);
add(spinnerDayBirth);
这些说明之间只有几行,但从未接触过此JSpinner。
所以我想知道为什么我不能获得普通的JSpinner。
我有同样的问题。 我只使用了spinnerModel,然后尝试了您的程序,它也起作用了。 有一件事情要做-重新设置模型。 如果要显示微调器,则必须再次设置新的微调器模型。
例如,我键入此代码:
public void method() {
jPanel2.setLocation(0, 96);
jPanel2.setSize(getWidth(), getHeight() - 96);
jPanel2.getHeight() - jButton1.getHeight() - 50);
jSpinner1.setModel(new SpinnerNumberModel(2,1,10,1)); //<- this is line you need to type
jSpinner1.setSize(60, 25);
jSpinner1.setLocation(0,0);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.