| about ProgressBar [message #371021] |
Mon, 16 June 2003 20:21  |
Eclipse User |
|
|
|
hi,
I have a demo program like this, but always finished immediately, I
don't know why, would you like to help me? thanks in advance!
Below is the demo:
package advancedWidget;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class ProgressBarDemo1 {
public static Display myDisplay;
public static boolean internalCall = false;
public static void main(String[] args) {
internalCall = true;
myDisplay = new Display();
ProgressBarDemo1 pbd = new ProgressBarDemo1();
pbd.runDemo(myDisplay);
}
public void runDemo(Display display) {
myDisplay = display;
Shell shell = new Shell(display);
shell.setSize(300, 300);
shell.setText("Progress Bar Demo");
ProgressBar progressBar1 = new ProgressBar(shell, SWT.HORIZONTAL);
progressBar1.setMinimum(0);
progressBar1.setMaximum(100);
progressBar1.setBounds(10,10,250,20);
for (int i = 0; i < 100; i++) {
sleep();
progressBar1.setSelection(i);
}
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
if (internalCall)
display.dispose();
}
/**
*
*/
private void sleep() {
long i = 0;
while (i < 1110000)
i++;
}
}
--
linuxman
========
I love Debian
|
|
|
| Re: about ProgressBar [message #371046 is a reply to message #371021] |
Tue, 17 June 2003 09:46  |
Eclipse User |
|
|
|
Originally posted by: steve_northover.ca.ibm.com
You need to open the shell.
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class ProgressBarDemo1 {
public static Display myDisplay;
public static boolean internalCall = false;
public static void main(String[] args) {
internalCall = true;
myDisplay = new Display();
ProgressBarDemo1 pbd = new ProgressBarDemo1();
pbd.runDemo(myDisplay);
}
public void runDemo(Display display) {
myDisplay = display;
Shell shell = new Shell(display);
shell.setSize(300, 300);
shell.setText("Progress Bar Demo");
ProgressBar progressBar1 = new ProgressBar(shell, SWT.HORIZONTAL);
progressBar1.setMinimum(0);
progressBar1.setMaximum(100);
progressBar1.setBounds(10, 10, 250, 20);
shell.open();
for (int i = 0; i < 100; i++) {
sleep();
progressBar1.setSelection(i);
}
// shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
if (internalCall)
display.dispose();
}
/**
*
*/
private void sleep() {
long i = 0;
while (i < 1110000)
i++;
}
}
"Su Baochen" <linuxman@263.net> wrote in message
news:bclmtm$6nv$1@rogue.oti.com...
> hi,
>
> I have a demo program like this, but always finished immediately, I
> don't know why, would you like to help me? thanks in advance!
>
> Below is the demo:
>
> package advancedWidget;
>
> import org.eclipse.swt.*;
> import org.eclipse.swt.widgets.*;
>
> public class ProgressBarDemo1 {
>
> public static Display myDisplay;
> public static boolean internalCall = false;
>
> public static void main(String[] args) {
> internalCall = true;
> myDisplay = new Display();
> ProgressBarDemo1 pbd = new ProgressBarDemo1();
> pbd.runDemo(myDisplay);
> }
>
> public void runDemo(Display display) {
> myDisplay = display;
> Shell shell = new Shell(display);
> shell.setSize(300, 300);
> shell.setText("Progress Bar Demo");
>
> ProgressBar progressBar1 = new ProgressBar(shell, SWT.HORIZONTAL);
> progressBar1.setMinimum(0);
> progressBar1.setMaximum(100);
> progressBar1.setBounds(10,10,250,20);
>
> for (int i = 0; i < 100; i++) {
> sleep();
> progressBar1.setSelection(i);
> }
>
> shell.open();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> if (internalCall)
> display.dispose();
> }
>
> /**
> *
> */
> private void sleep() {
> long i = 0;
> while (i < 1110000)
> i++;
> }
>
> }
>
>
> --
> linuxman
> ========
> I love Debian
>
|
|
|
Powered by
FUDForum. Page generated in 0.06175 seconds