⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testa.java

📁 RFID读写器调用实例程序。RFID读写器是远望谷804系列。通过JNI调用远望谷API。 提供读
💻 JAVA
字号:
package test.zyy;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class TestA {

	
	private static Text text;
	public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell();
		final GridLayout gridLayout = new GridLayout();
		shell.setLayout(gridLayout);
		shell.setText("GridLayout test");
		{
			final Label label = new Label(shell, SWT.NONE);
			final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
			label.setLayoutData(gridData);
			label.setText("label");
		}
		{
			final Composite composite = new Composite(shell, SWT.NONE);
			composite.setLayout(new GridLayout());
			composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
			{
				final Button button = new Button(composite, SWT.NONE);
				button.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(final SelectionEvent arg0)
					{
						String oldText = text.getText();
						text.setText("oldText" + "\n" + "Hello,This SWT.");
					}
				});
				button.setLayoutData(new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_END));
				button.setText("按我");
			}
			{
				final Button button = new Button(composite, SWT.NONE);
				button.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(final SelectionEvent arg0)
					{
						TestA testA = new TestA();
						SampleThread sampleThread = testA.new SampleThread();
						sampleThread.setPriority(Thread.MAX_PRIORITY);
						sampleThread.run();
					}
				});
				button.setLayoutData(new GridData());
				button.setText("打开一个新线程");
			}
			{
				final Button button = new Button(composite, SWT.NONE);
				button.setLayoutData(new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING));
				button.setText("推出");
			}
		}
		shell.open();

		{
			text = new Text(shell, SWT.BORDER);
			final GridData gd_text = new GridData(SWT.FILL, SWT.CENTER, true, false);
			gd_text.heightHint = 100;
			text.setLayoutData(gd_text);
		}
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
	}
	
	class SampleThread extends Thread
	{
		SampleThread()
		{
			String oldText = TestA.text.getText();
			TestA.text.setText(oldText + "\n" + "Start a Thread now.");
		}
		
		public void run()
		{
			while (true)
			{
				try
				{
					Thread.currentThread().sleep(1000);
					TestA.text.append("\n" + "Thread words...");
					
				} catch (Exception e)
				{
					// TODO: handle exception
				}
			}
		}
	}
	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -