> 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!