0

I have this JTable where the user inserts bus timetables. And I want it to have Windows like time editing template (being able to enter time from keyboard and mouse). Like:

12:00↕

Arrows meaning two buttons up/down for moving hours and minutes.

I couldn't find the premade JComponent like this or to be more precise I couldn't name it properly for google search, so don't get angry with such simple question, but how to do it?

TheGrandDuke
  • 101
  • 4

2 Answers2

0

if you're bound to use swing you have to write your own TableCellEditor, best practive would be to sublass AbstractCellEditor.

Use JSpinner to edit the values, JSpinner is the up/down-Button widget...

if you have furhter question, feel free to ask more on stackoverflow....

Martin Frank
  • 3,445
  • 1
  • 27
  • 47
0

You might want to look at this. The basic idea is that you override the SpinnerEditor class and add a spinner in the cell. To do what you want and have a layout like JSpinner:JSpinner, you should probably add a JLabel and another JSpinner. Also, the getCellEditorValue() method will have to return some sort of time object (unless you want to use military time).

Community
  • 1
  • 1
M3579
  • 890
  • 2
  • 11
  • 22