Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn MacLeod2010-04-27 19:06:24 +0000
committerCarolyn MacLeod2010-04-27 19:06:24 +0000
commit32ec347162901a46f221da4b796a98d0e2dbc35c (patch)
tree91aa1ca2ead3e7e55bc2adb79d0eb2d9140352e4 /examples/org.eclipse.swt.examples
parent2e4214882a11a1ae187aa95dc74b2d0b5d6627bf (diff)
downloadeclipse.platform.swt-32ec347162901a46f221da4b796a98d0e2dbc35c.tar.gz
eclipse.platform.swt-32ec347162901a46f221da4b796a98d0e2dbc35c.tar.xz
eclipse.platform.swt-32ec347162901a46f221da4b796a98d0e2dbc35c.zip
use int instead of string to specify shape
Diffstat (limited to 'examples/org.eclipse.swt.examples')
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/AccessibleShapesExample.java14
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/Shape.java34
2 files changed, 26 insertions, 22 deletions
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/AccessibleShapesExample.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/AccessibleShapesExample.java
index 98888c48f9..ed82a30738 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/AccessibleShapesExample.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/AccessibleShapesExample.java
@@ -10,15 +10,15 @@
*******************************************************************************/
package org.eclipse.swt.examples.accessibility;
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
/**
* This example creates some Shapes in a Shell and uses a FillLayout to position them.
* The Shape class is a simple example of the use of the SWT Accessibility API.
* A Shape is accessible, but it does not have any accessible children.
*/
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
public class AccessibleShapesExample {
static Display display;
static Shell shell;
@@ -30,15 +30,15 @@ public class AccessibleShapesExample {
Shape redSquare = new Shape(shell, SWT.NONE);
redSquare.setColor(SWT.COLOR_RED);
- redSquare.setShape("square");
+ redSquare.setShape(Shape.SQUARE);
Shape blueCircle = new Shape(shell, SWT.NONE);
blueCircle.setColor(SWT.COLOR_BLUE);
- blueCircle.setShape("circle");
+ blueCircle.setShape(Shape.CIRCLE);
Shape greenSquare = new Shape(shell, SWT.NONE);
greenSquare.setColor(SWT.COLOR_GREEN);
- greenSquare.setShape("square");
+ greenSquare.setShape(Shape.SQUARE);
shell.pack();
shell.open();
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/Shape.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/Shape.java
index c2e063f1c3..7d4e5c0b53 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/Shape.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/Shape.java
@@ -25,9 +25,12 @@ import org.eclipse.swt.accessibility.*;
* "label" or "static text" whose name is its color and shape.
*/
public class Shape extends Canvas {
+ static final int SQUARE = 0;
+ static final int CIRCLE = 1;
+ static final int TRIANGLE = 2;
static ResourceBundle bundle = ResourceBundle.getBundle("examples_accessibility");
int color = SWT.COLOR_BLUE;
- String shape = "square";
+ int shape = SQUARE;
/**
* Constructs a new instance of this class given its parent
@@ -51,7 +54,7 @@ public class Shape extends Canvas {
gc.setBackground(c);
Rectangle rect = getClientArea();
int length = Math.min(rect.width, rect.height);
- if (shape.equals(bundle.getString("circle"))) {
+ if (shape == CIRCLE) {
gc.fillOval(0, 0, length, length);
} else {
gc.fillRectangle(0, 0, length, length);
@@ -97,15 +100,16 @@ public class Shape extends Canvas {
getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent e) {
MessageFormat formatter = new MessageFormat("");
- formatter.applyPattern(bundle.getString("name"));
- String colorName = bundle.getString("color" + color);
- e.result = formatter.format(new String [] {colorName, shape}); //$NON_NLS$
+ formatter.applyPattern(bundle.getString("name")); //$NON_NLS$
+ String colorName = bundle.getString("color" + color); //$NON_NLS$
+ String shapeName = bundle.getString("shape" + shape); //$NON_NLS$
+ e.result = formatter.format(new String [] {colorName, shapeName}); //$NON_NLS$
}
});
getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
public void getRole(AccessibleControlEvent e) {
- e.detail = ACC.ROLE_LABEL;
+ e.detail = ACC.ROLE_GRAPHIC;
}
public void getState(AccessibleControlEvent e) {
e.detail = ACC.STATE_FOCUSABLE;
@@ -121,17 +125,17 @@ public class Shape extends Canvas {
* @return the color, which may be any of the SWT.COLOR_ constants
*/
public int getColor () {
- return this.color;
+ return color;
}
/**
* Return the receiver's shape.
- * The default shape is "square".
+ * The default shape is SQUARE.
*
- * @return the shape name string, which may be either "circle" or "square"
+ * @return the shape, which may be either CIRCLE or SQUARE
*/
- public String getShape () {
- return this.shape;
+ public int getShape () {
+ return shape;
}
/**
@@ -145,12 +149,12 @@ public class Shape extends Canvas {
}
/**
- * Set the receiver's shape to the specified shape name string.
- * The default shape is "square".
+ * Set the receiver's shape to the specified shape.
+ * The default shape is SQUARE.
*
- * @param shape a string that can be either "circle" or "square"
+ * @param shape an int that can be either CIRCLE or SQUARE
*/
- public void setShape (String shape) {
+ public void setShape (int shape) {
this.shape = shape;
}
}

Back to the top