I wanted to know how to add 2 small button into a cell. This is used for 'Quantity' column in my jtable.
I want to do as the image above, user are allowed to edit the number inside or clicking add or minus the number, how do I do it?
I wanted to know how to add 2 small button into a cell. This is used for 'Quantity' column in my jtable.
I want to do as the image above, user are allowed to edit the number inside or clicking add or minus the number, how do I do it?
The two arrows are part of a component called a Spinner
. You can use a JSpinner
to create textbox and use the SpinnerNumberModel
to allow it to use numerical values:
JSpinner spinner = new JSpinner();
spinner.setModel(new SpinnerNumberModel());
You can read more about spinners in the Java documentation
To add it to a table, you will need a custom class which extends DefaultCellEditor
. A few examples can be found here: