zoukankan      html  css  js  c++  java
  • SWT自定义选项卡CTabFolder

     

    SWT自定义选项卡CTabFolder

    学习了:http://blog.csdn.net/dreajay/article/details/17391731

    package com.swt;
    
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.custom.CTabFolder;
    import org.eclipse.swt.custom.CTabFolder2Adapter;
    import org.eclipse.swt.custom.CTabFolderEvent;
    import org.eclipse.swt.custom.CTabItem;
    import org.eclipse.swt.graphics.Color;
    import org.eclipse.swt.graphics.Image;
    import org.eclipse.swt.layout.GridData;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;
    
    public class Test02 {
        public static void main(String[] args) {
             final Display display = Display.getDefault();   
             final Shell shell = new Shell();   
             shell.setSize(296, 255);   
             shell.setText("CTabFolder 练习");   
             shell.setLayout(new GridLayout());   
             //   
    
             shell.open();   
    
             final CTabFolder tabFolder = new CTabFolder(shell, SWT.NONE|SWT.CLOSE| SWT.BORDER);   
             tabFolder.addCTabFolder2Listener(new CTabFolder2Adapter() {   
                 public void minimize(CTabFolderEvent event) {   
                         tabFolder.setMinimized(true);   
                         tabFolder.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));   
                         shell.layout(true);//刷新布局   
                 }   
                 public void maximize(CTabFolderEvent event) {   
                         tabFolder.setMaximized(true);   
                         tabFolder.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));   
                         shell.layout(true);   
                 }   
                 public void restore(CTabFolderEvent event) {   
                         tabFolder.setMinimized(false);   
                         tabFolder.setMaximized(false);   
                         tabFolder.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));   
                         shell.layout(true);   
                 }   
             });   
             //tabFolder.setBounds(0, 0, 283, 211);   
             tabFolder.setTabHeight(20);   
             tabFolder.marginHeight = 5;   
             tabFolder.marginWidth = 5;   
             tabFolder.setMaximizeVisible(true);   
             tabFolder.setMinimizeVisible(true);   
             tabFolder.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));   
             //下面两个是设置固定的背景色和前景色   
    //         tabFolder.setBackground(display.getSystemColor(SWT.COLOR_BLUE));   
    //         tabFolder.setForeground(display.getSystemColor(SWT.COLOR_WHITE));   
             //下面是设置渐变色   
    //         Color[] color=new Color[4];   
    //         color[0]=display.getSystemColor(SWT.COLOR_DARK_BLUE);   
    //         color[1]=display.getSystemColor(SWT.COLOR_BLUE);   
    //         color[2]=display.getSystemColor(SWT.COLOR_DARK_GRAY);   
    //         color[3]=display.getSystemColor(SWT.COLOR_WHITE);   
    //         int[] intArray=new int[]{25,45,100};   
    //         tabFolder.setSelectionBackground(color, intArray);   
             //这是设置了背景颜色,但是如果同时设置了背景图片的话以背景图片优先   
             tabFolder.setSimple(false);//设置圆角   
    //         tabFolder.setUnselectedCloseVisible(true);   
             for (int i = 1; i < 4; i++) {   
                 CTabItem item = new CTabItem(tabFolder, SWT.None|SWT.MULTI|SWT.V_SCROLL);   
                 item.setText("选项卡" + i);   
                 Text t = new Text(tabFolder, SWT.None|SWT.MULTI|SWT.V_SCROLL|SWT.H_SCROLL|SWT.WRAP);   
                 t.setText("这是选项卡可以控制的文字" + i+"
    
    世界第一等
    
    一路顺风");   
                 item.setControl(t);   
    
             }   
             Image image=new Image(display,"D:\label.jpg");   
             shell.setImage(image);     
             shell.setSize(300, 200);   
             shell.layout();   
             while (!shell.isDisposed()) {   
                 if (!display.readAndDispatch())   
                     display.sleep();   
             } 
        }
    }
  • 相关阅读:
    #QCon#北京2011大会“更有效地做测试”专题Slides资料
    长草了,冒个泡
    很好的一个书单
    团购——以价格换体验
    rpm deb命令集合[转]
    一个自动copy文件到指定目录的小程序
    ubuntulinux下的精品软件大汇总
    解决星际译王不朗读单词问题
    数据结构实验三:二叉树及其应用
    数据结构实验六:内部排序技术
  • 原文地址:https://www.cnblogs.com/stono/p/7464085.html
Copyright © 2011-2022 走看看