如何在 Jspinner 中制作时间格式? [英] How to make a time format in Jspinner?

查看:34
本文介绍了如何在 Jspinner 中制作时间格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何制作这样的时间格式小时:分钟:秒,毫秒,毫秒

How to make a time format like this hourhour:minuteminute:secondsecond,milisecondmilisecondmilisecond

当我使用 NET bean 的可视化 GUI 制作这个微调器时,只使用一个 Jspinner.

using only one Jspinner when I make this spinner using visual GUI of NET beans.

推荐答案

您需要同时使用 SpinnerDateModelJSpinner.DateEditor 和正确的日期格式模式:

You need to use both, SpinnerDateModel and JSpinner.DateEditor with the correct date format pattern:

public class JSpinnerDateFormat extends JFrame {
    public JSpinnerDateFormat() {
        super("JSpinner Date Format");
        JSpinner spinner = new JSpinner();
        spinner.setModel(new SpinnerDateModel());
        spinner.setEditor(new JSpinner.DateEditor(spinner, "HH:mm:ss.SSS"));
        add(spinner);
        pack();
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
    }

    public static void main(String[] args) {
        new JSpinnerDateFormat();
    }
}

这篇关于如何在 Jspinner 中制作时间格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆