tabclass.java

来自「eclipse cookbook the source code of the」· Java 代码 · 共 37 行

JAVA
37
字号
package org.cookbook.ch10;

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class TabClass
{
	public static void main(String[] args)
	{
		Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setText("Tab Folder Example");
		shell.setSize(450, 250);

		final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER);

		for (int loopIndex = 0; loopIndex < 10; loopIndex++)
		{
			TabItem tabItem = new TabItem(tabFolder, SWT.NULL);
			tabItem.setText("Tab " + loopIndex);

			Text text = new Text(tabFolder, SWT.BORDER);
			text.setText("This is page " + loopIndex);
			tabItem.setControl(text);
		}
		tabFolder.setSize(400, 200);

		shell.open();
		while (!shell.isDisposed())
		{
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}

⌨️ 快捷键说明

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