I am writing a GUI application in Java, where I am supposed to add, delete and edit some items in a JTable
. The table is located in one JFrame
where I also put buttons for adding, editing and deleting. When I click on the add button, it opens a new frame where I put in the data about a specific object, then that object goes into the table of the previous form and also goes into an ArrayList
of such objects. The adding works great.
Now, when I want to edit an item, I select it from the table and want to open the same frame which I use for adding. The form gets populated with the data of the selected object and I edit the data and want to save it to the table and the array list in such way that only the edited object gets saved and the original gets deleted. Here I have some problems.
Does anyone have an idea on what the best way to do this would be?