Skip to content
Advertisement

Adding Buttons inside cell of JTable along with data?

Is it possible to add buttons inside the JTable cell along with data? What I am trying to do is to create a table with columns which display data(number) from the database, and two buttons to increase/decrease the number inside the same cell.

|ID | Quantity|
|06| 2 [+][-] |

it would be something like above with [+][-] being buttons. So when I press [+], the number will change to 3 and 1 if pressing [-].

Advertisement

Answer

Yes, it is possible, although It won’t be easy.

You have to write your own custom cell renderer and your own cell editor.

This is a sample I made in 5 minutes:

sample

It is far from perfect, but shows the concept.

Here’s the source code:

JavaScript

Here’s a thread that may be interesting and here.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement