Sunday
Jul062008
SWT StyledText SuperClass
Sunday, July 6, 2008 at 02:07PM I extended a superclass of StyledText to Add support for undo and redo operations.
First lets import a few things we are going to need:
import java.util.LinkedList;
import java.util.List;
import org.eclipse.swt.custom.ExtendedModifyEvent;
import org.eclipse.swt.custom.ExtendedModifyListener;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Composite;
The LinkedList and List java.util routines are needed because our undo and redo additions are going to need a place to store on a couple of stacks the data to undo or redo. Lets start by creating a class "MyStyledText" that extends the SWT StyledText class.
public class MyStyledText extends StyledText {
private class undoRedoItem {
public Character Action;
public int Location;
public String Data;
public undoRedoItem(Character Action,
int Location, String Data) {
this.Action = Action;
this.Location = Location;
this.Data = Data;
}
}
in
Java,
Programming
Java,
Programming 

Reader Comments