wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Do multiple-step enabled Undo/Redo JButton on toolsbar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Do multiple-step enabled Undo/Redo JButton on toolsbar?" Watch "Do multiple-step enabled Undo/Redo JButton on toolsbar?" New topic
Author

Do multiple-step enabled Undo/Redo JButton on toolsbar?

Kenny Smith
Greenhorn

Joined: Jan 08, 2002
Posts: 9
Hello, everybody.
Now, I would like to create multiple-step enabled Undo/Redo JButton just like the "Back" "Forward" buttons of IE or Netscape. It looks like a compound-button with a JToggleButton and a dropdown menu.
Does any one know how to implement such a button??


Kenny Smith
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
Depends on what you are going to need to undo/redo. If its text, you could just store some copys of the complete text based on some *text changed* criterion. Then if they hit undo, you replace what's there(or cache it for redo) with the last copy you have. The number of undo/redos would only be limited to how many copies of the info you could stand to keep. That would work for small text areas. If you were trying to do a text editor that could hold huge amounts of text, you'd have to work up a different system of watching and saving changes.
If it's not text I guess you could do something similar where you just have to track your data and store copies based on changes made.
As for allowing selection of which particular change they were going back to, You would have to figure out how you were going to display it to the user. Show him the time of the change save(have to save the time with the change)? Show him the beginning of the text changed(hard to implement)? Just show him set value like "Back 1","Back 2"(easiest)?
HTH
[ February 21, 2003: Message edited by: Chris Shepherd ]
Kenny Smith
Greenhorn

Joined: Jan 08, 2002
Posts: 9
Thanks, Chris.
Probably I didn't make it clear on what I really need.
I do know how to support Undo/Redo based on package javax.swing.undo.
What I want to know is, how to draw such a button on screen and make it behaves like a "Back" button of IE. The button should have 2 "sub-button", one is normal, and the other looks like a down-arrow that can bring up a drop-down menu on the screen. And the 2 "sub-button" have some common properties like show border or not at the same time, enabled/disabled together, etc.
Does this make sense?
.... :roll:
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
ooooh.... well you could put 2 borderless buttons together on a small JPanel and put a border on the JPanel. Don't know right off how you want to display the droplist button, although the back button should be easy. You should be able to do everything together with those buttons on the same panel.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Do multiple-step enabled Undo/Redo JButton on toolsbar?
 
Similar Threads
Word-based text undo/redo
Trigger Undo from Javascript?
Data structure in real world
What UML Tool(s) are you using for SCEA Beta Part II?
IntelliJ 4.0: My favorite shortcuts