Undo

F

freesoft_2000

Hi everyone,

I am trying to add an undo listener to a jtable but could
not get it to work. Does anyone know how to add a undo function to a jtable
assuming the default cell editor component is a jtextfield?

A small code sample would be helpful

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
O

Oscar kind

freesoft_2000 said:
I am trying to add an undo listener to a jtable but could
not get it to work. Does anyone know how to add a undo function to a jtable
assuming the default cell editor component is a jtextfield?

AFAIK, JTable, JTextField and the other Swing components do not support
undo by themselves. This means that you'll need to keep a stack of past
values, and reinsert those values when a specific action is triggered.

Thus you need:
- A (limited) stack of past values or changes
- A ChangeListener that pushes records on this stack for all changes
- An ActionListener that pops records from the stack and undoes changes

The ChangeListener is tied to all components that may be undone; the
ActionListener is tied to the undo button (or menu item, ...).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top