Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java
index 0102f2e17c..9ef531defa 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java
@@ -29,6 +29,9 @@ class StyledTextTab extends ScrollableTab {
/* Buttons for adding StyleRanges to StyledText */
Button boldButton, italicButton, redButton, yellowButton;
Image boldImage, italicImage, redImage, yellowImage;
+
+ /* Variables for saving state. */
+ StyleRange[] styleRanges;
/**
* Creates the Tab within a given instance of ControlExample.
@@ -90,6 +93,11 @@ class StyledTextTab extends ScrollableTab {
styledText.setText (ControlExample.getResourceString("Example_string"));
styledText.append ("\n");
styledText.append (ControlExample.getResourceString("One_Two_Three"));
+
+ if (styleRanges != null) {
+ styledText.setStyleRanges(styleRanges);
+ styleRanges = null;
+ }
}
/**
@@ -240,6 +248,17 @@ class StyledTextTab extends ScrollableTab {
}
/**
+ * Disposes the "Example" widgets.
+ */
+ void disposeExampleWidgets () {
+ /* store the state of the styledText if applicable */
+ if (styledText != null) {
+ styleRanges = styledText.getStyleRanges();
+ }
+ super.disposeExampleWidgets();
+ }
+
+ /**
* Gets the "Example" widget children.
*/
Control [] getExampleWidgets () {

Back to the top