JTextArea Filters and/or Inputs of time (00:00:00) Java

后端 未结 3 1449
误落风尘
误落风尘 2021-01-26 12:47

There\'s a section of my program where the user should have the ability to edit an amount of time. There will be a default amount of time already set but the user should be able

3条回答
  •  时光说笑
    2021-01-26 13:31

    You can use JSpinner to achieve this. I hope the below piece of would help.

    JFrame frame = new JFrame("Date Picker");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JSpinner timeSpinner = new JSpinner( new SpinnerDateModel());
    
    JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "HH:mm:ss");
    timeSpinner.setEditor(timeEditor);
    timeSpinner.setValue(new Date());
    
    frame.add(timeSpinner);
    
    frame.setVisible(true);
    frame.pack();
    

提交回复
热议问题