I want to create a table with two columns {FirstName, LastName}, I add the items by filling two jtextfields and click on add button . Everything works fine. But I want edit and delete button for every row I am adding. edit button will enable that particular row editable. delete button will delete that particular row.
Asked
Active
Viewed 510 times
0
-
Welcome by StackOverflow. Please post your code in form of [mcve], so we can better help you. – Sergiy Medvynskyy Nov 14 '19 at 07:51
-
I have a personal issue with "buttons in tables", it's just not required, it's messy and a bad user experience. Instead, you could do something [like this](https://stackoverflow.com/questions/25070511/add-jbutton-to-each-row-of-a-jtable/25071138#25071138). Instead of an edit button, just use a selection listener to determine when a row is selected. You should also take some time to go over [How to Use Tables](https://docs.oracle.com/javase/tutorial/uiswing/components/table.html), as `JTable` is fully capable of editing the data directly in the table itself – MadProgrammer Nov 14 '19 at 08:01
-
Thanks but this is a requirement for a client project. for every row there should be edit and delete button with respected icons. (edit icon and delete icon). on click edit that row should become editable. please I have tried everything. – devilmk Nov 14 '19 at 08:52
-
See: https://stackoverflow.com/questions/25707854/unable-to-add-jbuttons-wrapped-in-jpanel-into-jtable/25711071#25711071 – camickr Nov 14 '19 at 15:24
-
Thanks camickr , I I followed the same which you have posted , Now i am able to add the edit and delete button to the every row of the table. – devilmk Nov 15 '19 at 04:32