63 800
Assignments Done
99,5%
Successfully Done
In August 2018

Answer to Question #38381 in Java | JSP | JSF for Shanaka Perera

Question #38381
how to add addUndoableEditListener to a jTable rows
I worked undo/redo function on a jTextField using code below. I tried to add UndoableEditListener to jTable but I got nothing.When you add a row to the table with wrong details then you should be able to erase that row using Control + Z as well as you press Control + Y the same row should be visible in the jTable with early mentioned values also. I think it's not implementing a CellEditor. Please help me on this.
final UndoManager undo = new UndoManager();
JTextField jTextField1 = new JTextField();
Document doc = jTextField1.getDocument();
doc.addUndoableEditListener(new UndoableEditListener() {

public void undoableEditHappened(UndoableEditEvent evt) {
undo.addEdit(evt.getEdit());
}
});
jTextField1.getActionMap().put("undo", new AbstractAction("undo") {

public void actionPerformed(ActionEvent arg0) {
try {
if (undo.canUndo()) {
Expert's answer

Not answered

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions