سؤال

I have a JTable where a user can create a custom report. They can add/remove "rows" which are columns in the report.

I want to have them be able to "undo" a row deletion. Currently they can just reset the whole report back to the standard report via a button. This is OK, but there's a lot of columns and some users are grumbling about the time they can lose if they accidentally delete a row.

I figure I can create a stack easily enough that tracks the rows deleted, so it'll just be a "add" event that I can call on a key event listener (listen for ctrl-z, or a button perhaps). Once it's called, it'll just pop off the stack and add the row.

But, since I'm using the Netbeans platform anyway, I'd love to tie into the edit->undo functionality that exists there.

What are the commands, or API calls that I can make to tie into that undo functionality that exists in the platform?

هل كانت مفيدة؟

المحلول

You'll need to add an action to your application (using the wizard).

Maybe this comes handy:

  1. Related issue: http://netbeans.org/bugzilla/show_bug.cgi?id=204828
  2. Related tutorial: https://blogs.oracle.com/geertjan/entry/enabling_undo_redo_functionality_on
  3. You can also just add it as a right click menu to the table itself: JTable Right-Click popupmenu in Netbeans
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top