小编mus*_*oid的帖子

多个JSpinner初始化不同

我的应用程序中有2个JSpinner,我为它们设置了模型,编辑器,数字格式.但是,当我运行应用程序时,第二个应用程序最初不会显示小数部分.这看起来像聚焦问题.

所以首先初始化0.0但第二个初始化为0; 我希望第二个与第一个相同.我想念这一步吗?这是我的代码如下.

在此输入图像描述

这是我的代码

import java.text.DecimalFormat;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;

public class NewJFrame extends javax.swing.JFrame {
    private final JSpinner.NumberEditor editor;
    DecimalFormat format , format2 ; 
    private final JSpinner.NumberEditor editor1;

    /**
     * Creates new form NewJFrame
     */
    public NewJFrame() {
        initComponents();

        SpinnerNumberModel model1 = new SpinnerNumberModel(0.0,-1000.0 ,1000.0,0.1); 
        this.jSpinner1.setModel(model1);
        editor = new JSpinner.NumberEditor(this.jSpinner1);
        this.jSpinner1.setEditor(editor);
        format = editor.getFormat(); 
        format.setMinimumFractionDigits(1);

        SpinnerNumberModel model2 = new SpinnerNumberModel(0.0,-1000.0 ,1000.0,0.1); 
        this.jSpinner2.setModel(model2);
        editor1 = new JSpinner.NumberEditor(this.jSpinner2);
        this.jSpinner2.setEditor(editor1);
        format2 = editor1.getFormat(); 
        format2.setMinimumFractionDigits(1);


    }

    /**
     * This method is called from …
Run Code Online (Sandbox Code Playgroud)

java swing editor jspinner number-formatting

4
推荐指数
2
解决办法
237
查看次数

不能将单选按钮选择保存到百里香的数据库中

我有表格和内部我有单选按钮选项,我有控制器类和模型.我可以成功保存其他数据,但单选按钮选项始终反映为数据库为0.我相信百里香的单选按钮实现有问题.

<form id="add" role="form" th:action="@{/add}" method="post" th:object="${radiobutton}">
    <input type="hidden" th:field="*{id}"/>

    <div class="form-group">
        <label>is it new</label>
        <label class="radio-inline">
            <input type="radio" name="optionsRadiosInline1" id="optionsRadiosInline1"
                   value="true" th:checked="*{isNew}"/>Yes
        </label>
        <label class="radio-inline">
            <input type="radio" name="optionsRadiosInline1" id="optionsRadiosInline2"
                   value="false" th:checked="*{isNew} == false"/>No
        </label>
    </div>

</form>
Run Code Online (Sandbox Code Playgroud)

thymeleaf

1
推荐指数
1
解决办法
3908
查看次数

标签 统计

editor ×1

java ×1

jspinner ×1

number-formatting ×1

swing ×1

thymeleaf ×1