Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Undo

Reply
 
 
freesoft_2000
Guest
Posts: n/a
 
      02-13-2005
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

 
Reply With Quote
 
 
 
 
Oscar kind
Guest
Posts: n/a
 
      02-13-2005
freesoft_2000 <(E-Mail Removed)> wrote:
> 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, ...).


--
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website

PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      02-14-2005
Oscar kind wrote:
> 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.


http://java.sun.com/j2se/1.5.0/docs/...e-summary.html

/Thomas

--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to "undo" a database delete Morgan Bachu ASP .Net 13 08-31-2005 03:08 AM
Undo formatting tshad ASP .Net 5 04-13-2005 09:24 PM
How to open a "closed TAB" ( is there an UNDO command?) bd Firefox 5 01-05-2005 03:43 AM
How do I undo WebRequest.RegisterPrefix john farrow ASP .Net 0 04-13-2004 09:21 PM
Undo in TextBox Marco Liedekerken ASP .Net 0 06-26-2003 10:03 AM



Advertisments