• Post Reply Bookmark Topic Watch Topic
  • New Topic

Delete row from JTable as well as file i/o

 
Jessie Tan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m using JTable to displaying all my data that retrieve from the textfile.
I need to select the entire row and click onto the delete button. Then the row of data will be deleted as well as in the textfile.. i have no idea how to make this method work.. pls give me some advice.. thanks
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have no idea how to make which method work? Deleting a row from a JTable or removing data from a Text File.
Look, I am going to try and explain something here and this is truly meant to help you.
You have 2 issues here. Deleting a row from a JTable, which is a valid Swing question, and removing data from a text file which, while it is happening in a Swing application, has nothing to do with Swing at all.
So you need to concentrate on 1 issue at a time. This will make things easier for you. So, for example, get the row deletion in the JTable working. Once that is working, then work on your IO problem.
So, as far as the JTable row deletion, what have you tried?
 
Sebastiaan Kortleven
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the actionPerformed method of the delete button, check which row was selected (mytable.getSelectedRow()) and delete it from the data that you passed to the jtable on creation (or the tablemodel behind it) and then do a fireTableDataChanged on that model, this will get the table to take a new look at its data...
In the actionPerfomed method you also delete the row from the file...

gl
 
Jessie Tan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i'm still quite new to Java, that's why what u have said i understand but dunnoe how to apply it...
hope u can make it more detail...
Thanx a million...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!