简体   繁体   English

JSpinner没有显示

[英]JSpinner doesn't show

I really doesn't understand what it's going on with my JSpinner. 我真的不明白JSpinner发生了什么。 I instanciated it and then I tried to set it on my JPanel with a setBounds but the only thing I get is this : 我实例化了它,然后尝试使用setBounds在JPanel上设置它,但我唯一得到的是:

JSpinner

The little square on the middle is what should be my JSpinner.. 中间的小方块应该是我的JSpinner。

My code is like this : 我的代码是这样的:

private JSpinner spinnerDayBirth;
spinnerDayBirth = new JSpinner();
spinnerDayBirth.setBounds(280,351, 25, 25);
add(spinnerDayBirth);

They're few lines betweens each of these instructions but they never touch to this JSpinner. 这些说明之间只有几行,但从未接触过此JSpinner。

So I wonder why I can't get a normal JSpinner.. Thank you in advance ! 所以我想知道为什么我不能获得普通的JSpinner。

I had same problem. 我有同样的问题。 I worked with simply spinnerModel then I tried your program and it works too. 我只使用了spinnerModel,然后尝试了您的程序,它也起作用了。 There is one thing to do - re-set your model. 有一件事情要做-重新设置模型。 If you want the spinner to appear you have to set new spinner model again. 如果要显示微调器,则必须再次设置新的微调器模型。

for example i typed this code: 例如,我键入此代码:

    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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM