import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.*; import org.eclipse.swt.layout.*; public class ABB{ public static void main(String[] args){ Display display=new Display(); Shell shell=new Shell(display); shell.setText("选项卡TabFolder练习"); FillLayout layout=new FillLayout(); layout.marginHeight=20; layout.marginWidth=20; shell.setLayout(layout);//必须要有 //shell.setLayout(new FillLayout(SWT.HORIZONTAL));//必须要有 //创建选项卡 TabFolder tabFolder=new TabFolder(shell,SWT.TOP); //为选项卡添加标签对象 for(int i=0;i<4;i++){ TabItem item=new TabItem(tabFolder,SWT.NONE); item.setText("选项卡"+i); //为选项卡对象添加可控文本 Text text=new Text(tabFolder,SWT.NONE); text.setText("这是第"+i+"页"); //将选项卡标签与可控文本进行关联 item.setControl(text); } //打开窗口,进行窗口的显示 //shell.setSize(400,400); shell.pack(); shell.open(); while(!shell.isDisposed()){ //当窗口没有被释放的时候 if(!display.readAndDispatch()){ display.sleep(); } } display.dispose(); } }
选项卡TabFolder
猜你喜欢
转载自blog.csdn.net/Grace_1203/article/details/80066786
今日推荐
周排行