Undo selection in JComboBox

Hi,How can i add an undo selection functionality in a jComboBox? I know how it works in textcomponents and buttons but i have a problem with jComboBoxs.Thnx
[177 byte] By [virtual_gra] at [2007-10-3 9:10:31]
# 1
Quit cluttering the forum with multiple postings. You posted the same question 30 minutes ago: http://forum.java.sun.com/thread.jspa?threadID=783217
camickra at 2007-7-15 4:22:32 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks for your attention! But nobody even tried to help me
virtual_gra at 2007-7-15 4:22:32 > top of Java-index,Desktop,Core GUI APIs...
# 3
> Thanks for your attention! But nobody even tried to> help meThen reply to your own topic with an update of your status and what you have tried. Don't keep posting the same question.
zadoka at 2007-7-15 4:22:32 > top of Java-index,Desktop,Core GUI APIs...
# 4

> Hi,

>

> How can i add an undo selection functionality in a

> jComboBox? I know how it works in textcomponents and

> buttons but i have a problem with jComboBoxs.

>

> Thnx

Hi,

I won't claim to be an expert in the inner workings of the JComboBox class however from my experience, the way you would implement an undo functionality, at least the way I would do it, would be to implement an ordered collection (List or Stack or Queue, obviously not Set) to store something to remember the selection by...if the actual actual list contents can change dramatically or if the JComboBox is 'editable', then I would suggest storing objects.

Since Java stores objects as references rather than deep copying to create whole object instances, you would not have to worry about a whole ton of memory usage since only 1 copy of every object would ever be created.

Later, when the user invoked "Undo", if the object in question was the combo box, then you would just go to the last item in the list and set the selected index or value (depending on what you saved) to the value in the collection.

I don't have details or much code because I'm on my lunch break at work and don't work with java at my job, but try to come up with it on your own now and if you still can't do it, respond and I'll try to write something when I'm at home. Good Luck!

dragonprincea at 2007-7-15 4:22:32 > top of Java-index,Desktop,Core GUI APIs...
# 5
> But nobody even tried to help me So it was only 30 minutes!People answer questions when they know the answer and they have time, not just because you post a question.
camickra at 2007-7-15 4:22:32 > top of Java-index,Desktop,Core GUI APIs...