A JSpinner with min and max buttons

前端 未结 3 621
梦谈多话
梦谈多话 2021-01-24 23:11

I\'m looking for a JSpinner-like component that would provide built-in buttons that would immediately set the spinner value to the minimum or the maximum of the jspinner model.

3条回答
  •  囚心锁ツ
    2021-01-24 23:57

    I can't think of any component that would do it out of the box. But basically, a simple flow layout with a minus button, a spinner and a max button would do. Both buttons would have actionListeners that will ask the spinner for min and max values and set its value.

    Use a changeListener on the spinner to be notified of value changes both programatically (using your buttons) and through user interaction.

    Also, you could consider using a JCombobox if your values are discrete or a JSlider if they are not, as both components present upper and lower bounds more clearly to users.

    Regards, Stéphane

提交回复
热议问题