Ask Experts Questions for FREE Help !
Ask
    shanaka1992's Avatar
    shanaka1992 Posts: 5, Reputation: 1
    New Member
     
    #1

    Jan 14, 2014, 07:46 AM
    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 usingControl + 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()) {
    undo.undo();
    }
    } catch (CannotUndoException e) {
    }
    }
    });
    jTextField1.getInputMap().put(KeyStroke.getKeyStro ke("control Z"), "undo");

Check out some similar questions!

Jcombobox in jtable [ 0 Answers ]

I am setting a JComboBox in a JTable. The first item in the JComboBox is the JComboBox string object: javax.swing.JComboBox If I click on the JComboBox in the table column, it opens up with the items I have added. TableColumn col = Table.getColumnModel().getColumn(1);...

How to Knit Short Rows? [ 1 Answers ]

How do you knit short rows? I am confused on how to wrap around stitches.


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.