In Java Swing, do we have text component that will work just like how we set the time in Microwave.
By default system should display 00:00:00 (hh:mm:ss) in a textfield.
Users focus defaults in the far right of the text box in the far right position.
For example if user enters 00:00:85, then system should convert that to 01:25, similarly if user enters 00:08:99, then system should convert that to 00:9:39 (9 mins. 39 secs), similarly if user enters 00:03:00, then system should convert that to 00:03:00 (3 Minutes)
Please let me know if we have any component that works just like this or similar to this..
Thanks in Advance..
Out of the box, no. You will have to write some custom code.
You could use a
JFormattedTextFieldwith a custom format on it. See this post for an example. Only thing you will have to replace is theFormatby your own format.Another possibility is a
JSpinnerwith a custom model where you just loop through a set of fixed values (e.g. incrementing time by 5”). This is how my microwave works. I can just rotate a button which increases the time. I cannot ‘type’ anything