Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine2004-12-17 16:49:29 +0000
committerVeronika Irvine2004-12-17 16:49:29 +0000
commitf9229cc6eee57fe3cf0477ba6a7209197022f11b (patch)
tree1c0f1bed46d5fabb843cbb29de5cc7778007f859 /examples
parentb83bddbb42de9de21767f71989d7d9dbe3cf9afd (diff)
downloadeclipse.platform.swt-f9229cc6eee57fe3cf0477ba6a7209197022f11b.tar.gz
eclipse.platform.swt-f9229cc6eee57fe3cf0477ba6a7209197022f11b.tar.xz
eclipse.platform.swt-f9229cc6eee57fe3cf0477ba6a7209197022f11b.zip
*** empty log message ***
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java30
1 files changed, 16 insertions, 14 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java
index a651f38171..1160b2bd49 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java
@@ -23,11 +23,11 @@ import org.eclipse.swt.widgets.*;
public class Snippet151 {
-static int[] values;
+static int[] values = new int[0];
public static void main (String [] args) {
- final Display display = new Display();
- Shell shell = new Shell(display);
+ final Display display = new Display ();
+ Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
final Table table = new Table(shell, SWT.BORDER | SWT.VIRTUAL);
table.addListener(SWT.SetData, new Listener() {
@@ -41,20 +41,22 @@ public static void main (String [] args) {
public void run() {
int count = 0;
Random random = new Random();
- while (count++ < 2000) {
+ while (count++ < 500) {
if (table.isDisposed()) return;
- final int[] newValues = new int[1000];
- for (int i = 0; i < newValues.length; i++) {
- newValues[i] = random.nextInt();
+ // add 10 random numbers to array and sort
+ int grow = 10;
+ int[] newValues = new int[values.length + grow];
+ System.arraycopy(values, 0, newValues, 0, values.length);
+ int index = values.length;
+ values = newValues;
+ for (int j = 0; j < grow; j++) {
+ values[index++] = random.nextInt();
}
- Arrays.sort(newValues);
+ Arrays.sort(values);
display.syncExec(new Runnable() {
public void run() {
if (table.isDisposed()) return;
- if (values == null) {
- table.setItemCount(1000);
- }
- values = newValues;
+ table.setItemCount(values.length);
table.clearAll();
}
});
@@ -63,9 +65,9 @@ public static void main (String [] args) {
}
};
thread.start();
- shell.open();
+ shell.open ();
while (!shell.isDisposed() || thread.isAlive()) {
- if (!display.readAndDispatch()) display.sleep();
+ if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

Back to the top