package kk.server.*;import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;public class ServerTest {
private class UpdateTime extends Thread {
private int count = 0;
private boolean runFlag = true;
UpdateTime() { start(); }
public void run(){
while(true){
if (runFlag)
labtime.setText(Integer.toString(count++));
}
}
}
//private int count = 0;
private UpdateTime ut = null;
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
private Label labtime = null;
private Button btnbegin = null;
/**
* @param args
*/
public static void main(String[] args) {
Display display = Display.getDefault();
ServerTest thisClass = new ServerTest();
thisClass.createSShell();
thisClass.sShell.open(); while (!thisClass.sShell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
} /**
* This method initializes sShell
*/
private void createSShell() {
sShell = new Shell();
sShell.setText("Shell");
sShell.setSize(new org.eclipse.swt.graphics.Point(296,121));
labtime = new Label(sShell, SWT.CENTER);
labtime.setBounds(new org.eclipse.swt.graphics.Rectangle(9,9,272,26));
labtime.setText("0");
btnbegin = new Button(sShell, SWT.NONE);
btnbegin.setBounds(new org.eclipse.swt.graphics.Rectangle(99,43,79,25));
btnbegin.setText("Begin");
btnbegin.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (ut == null)
ut = new UpdateTime();
}
});
}}
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;public class ServerTest {
private class UpdateTime extends Thread {
private int count = 0;
private boolean runFlag = true;
UpdateTime() { start(); }
public void run(){
while(true){
if (runFlag)
labtime.setText(Integer.toString(count++));
}
}
}
//private int count = 0;
private UpdateTime ut = null;
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
private Label labtime = null;
private Button btnbegin = null;
/**
* @param args
*/
public static void main(String[] args) {
Display display = Display.getDefault();
ServerTest thisClass = new ServerTest();
thisClass.createSShell();
thisClass.sShell.open(); while (!thisClass.sShell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
} /**
* This method initializes sShell
*/
private void createSShell() {
sShell = new Shell();
sShell.setText("Shell");
sShell.setSize(new org.eclipse.swt.graphics.Point(296,121));
labtime = new Label(sShell, SWT.CENTER);
labtime.setBounds(new org.eclipse.swt.graphics.Rectangle(9,9,272,26));
labtime.setText("0");
btnbegin = new Button(sShell, SWT.NONE);
btnbegin.setBounds(new org.eclipse.swt.graphics.Rectangle(99,43,79,25));
btnbegin.setText("Begin");
btnbegin.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (ut == null)
ut = new UpdateTime();
}
});
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货