锘??xml version="1.0" encoding="utf-8" standalone="yes"?>精品国产亚洲第一区二区三区,亚洲成A人片77777国产,亚洲A∨无码无在线观看http://m.tkk7.com/zhanglongsr/category/41282.html璺極婕叾淇繙鍏紝鍚懼皢涓婁笅鑰屾眰绱紒zh-cnThu, 13 Aug 2009 10:48:20 GMTThu, 13 Aug 2009 10:48:20 GMT60SWT- GridLayout銆丟ridData銆丆omposite緇煎悎紺轟緥http://m.tkk7.com/zhanglongsr/articles/291049.htmlzhangxlzhangxlThu, 13 Aug 2009 09:27:00 GMThttp://m.tkk7.com/zhanglongsr/articles/291049.htmlhttp://m.tkk7.com/zhanglongsr/comments/291049.htmlhttp://m.tkk7.com/zhanglongsr/articles/291049.html#Feedback0http://m.tkk7.com/zhanglongsr/comments/commentRss/291049.htmlhttp://m.tkk7.com/zhanglongsr/services/trackbacks/291049.html    鏈枃緇煎悎浜咷ridLayout銆丟ridData銆丆omposite浠ュ強Tree銆乀reeItem鏋勯犱簡涓涓瘮杈冨鏉傜殑搴旂敤渚嬪瓙銆?br />
   /*---------- 鏋勯犱唬鐮?---------*/

public class GridLayoutObject {
 
 public void buildLayout(){
  
  Display display = new Display();
  Shell shell = new Shell(display);
  
  GridLayout configLayout = new GridLayout();
  configLayout.marginHeight = 0;
  configLayout.marginWidth = 0;
  
  shell.setLayout(configLayout);
  
  GridData gridData;
  
  SashForm form = new SashForm(shell,SWT.HORIZONTAL);
  gridData = new GridData(GridData.FILL_BOTH);
  form.setLayoutData(gridData);
    
     Composite cLeftSide = new Composite(form, SWT.BORDER);
     gridData = new GridData(GridData.FILL_BOTH);
     cLeftSide.setLayoutData(gridData);
    
     FormLayout layout = new FormLayout();
     cLeftSide.setLayout(layout);
      
     Composite cFilterArea = new Composite(cLeftSide, SWT.NONE);
     cFilterArea.setLayout(new FormLayout());
      
     final Text txtFilter = new Text(cFilterArea, SWT.BORDER);
     txtFilter.setText("hi");
     txtFilter.selectAll();
     txtFilter.setFocus();
    
     Label lblX = new Label(cFilterArea, SWT.WRAP);
     lblX.setText("l1");
    
     Label lblSearch = new Label(cFilterArea, SWT.NONE);
     lblSearch.setText("l2");
    
     Tree tree = new Tree(cLeftSide, SWT.NONE);
     FontData[] fontData = tree.getFont().getFontData();
     fontData[0].setStyle(SWT.BOLD);
     Font filterFoundFont = new Font(display, fontData);
    
     FormData formData;

       formData = new FormData();
       /*娉ㄦ剰錛?0錛屼唬琛?/
       formData.bottom = new FormAttachment(100, -5);
       formData.left = new FormAttachment(0, 0);
       formData.right = new FormAttachment(100, 0);
       cFilterArea.setLayoutData(formData);
      
       formData = new FormData();
       formData.top = new FormAttachment(0,5);
       formData.left = new FormAttachment(0, 5);
       lblSearch.setLayoutData(formData);

       formData = new FormData();
       formData.top = new FormAttachment(0,5);
       formData.left = new FormAttachment(lblSearch,5);
       formData.right = new FormAttachment(lblX, -3);
       txtFilter.setLayoutData(formData);

       formData = new FormData();
       formData.top = new FormAttachment(0,5);
       formData.right = new FormAttachment(100,-5);
       lblX.setLayoutData(formData);

       formData = new FormData();
       formData.top = new FormAttachment(0, 0);
       formData.left = new FormAttachment(0,0);
       formData.right = new FormAttachment(100,0);
       formData.bottom = new FormAttachment(cFilterArea,-1);
       tree.setLayoutData(formData);
      
       Composite cRightSide = new Composite(form, SWT.NULL);
       configLayout = new GridLayout();
       configLayout.marginHeight = 3;
       configLayout.marginWidth = 0;
       cRightSide.setLayout(configLayout);
  
       // Header
       Composite cHeader = new Composite(cRightSide, SWT.BORDER);
       configLayout = new GridLayout();
       configLayout.marginHeight = 3;
       configLayout.marginWidth = 0;
       configLayout.numColumns = 2;
       configLayout.marginRight = 5;
       cHeader.setLayout(configLayout);
       gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
       cHeader.setLayoutData(gridData);
  
       cHeader.setBackground(display.getSystemColor(SWT.COLOR_LIST_SELECTION));
       cHeader.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
      
       Label lHeader = new Label(cHeader, SWT.NULL);
       lHeader.setBackground(display.getSystemColor(SWT.COLOR_LIST_SELECTION));
       lHeader.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
       fontData = lHeader.getFont().getFontData();
       fontData[0].setStyle(SWT.BOLD);
       int fontHeight = (int)(fontData[0].getHeight() * 1.2);
       fontData[0].setHeight(fontHeight);
       Font headerFont = new Font(display, fontData);
       lHeader.setFont(headerFont);
       gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_BEGINNING);
       lHeader.setLayoutData(gridData);
      
       Label usermodeHint = new Label(cHeader, SWT.NULL);
       usermodeHint.setBackground(display.getSystemColor(SWT.COLOR_LIST_SELECTION));
       usermodeHint.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
       gridData = new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
       usermodeHint.setLayoutData(gridData);
      
       Composite cConfigSection = new Composite(cRightSide, SWT.NULL);
       StackLayout layoutConfigSection = new StackLayout();
       cConfigSection.setLayout(layoutConfigSection);
       gridData = new GridData(GridData.FILL_BOTH);
       gridData.horizontalIndent = 2;
       cConfigSection.setLayoutData(gridData);
  
  
       form.setWeights(new int[] {50,80});
      
       Listener scResizeListener = new Listener() {
    public void handleEvent(Event event) {
     setupSC((ScrolledComposite)event.widget);
    }
   };
       ScrolledComposite sc = new ScrolledComposite(cConfigSection, SWT.H_SCROLL | SWT.V_SCROLL);
         sc.setExpandHorizontal(true);
         sc.setExpandVertical(true);
         sc.setLayoutData(new GridData(GridData.FILL_BOTH));
        sc.getVerticalBar().setIncrement(16);
        sc.addListener(SWT.Resize, scResizeListener);
      
        ModelConfigSection a = new ModelConfigSection();
        Composite c = a.configSectionCreate(sc);
        sc.setContent(c);
       TreeItem item1 = new TreeItem(tree,SWT.NULL);
       item1.setText("璇存槑");
       item1.setData("Panel", sc);
       layoutConfigSection.topControl = sc;
      
       ScrolledComposite sc1 = new ScrolledComposite(cConfigSection, SWT.H_SCROLL | SWT.V_SCROLL);
          sc1.setExpandHorizontal(true);
          sc1.setExpandVertical(true);
          sc1.setLayoutData(new GridData(GridData.FILL_BOTH));
         sc1.getVerticalBar().setIncrement(16);
         sc1.addListener(SWT.Resize, scResizeListener);
   
   
       
       TreeItem item2 = new TreeItem(tree,SWT.NULL);
       item2.setText("緗戠粶閰嶇疆");
       item2.setData("Panel",sc1);

       ScrolledComposite sc2 = new ScrolledComposite(cConfigSection, SWT.H_SCROLL | SWT.V_SCROLL);
          sc2.setExpandHorizontal(true);
          sc2.setExpandVertical(true);
          sc2.setLayoutData(new GridData(GridData.FILL_BOTH));
         sc2.getVerticalBar().setIncrement(16);
         sc2.addListener(SWT.Resize, scResizeListener);
        
       TreeItem item21 = new TreeItem(item2,SWT.NULL);
       item21.setText("璺敱閰嶇疆");
       item21.setData("Panel", sc2);
      
      
       ScrolledComposite sc3 = new ScrolledComposite(cConfigSection, SWT.H_SCROLL | SWT.V_SCROLL);
          sc3.setExpandHorizontal(true);
          sc3.setExpandVertical(true);
          sc3.setLayoutData(new GridData(GridData.FILL_BOTH));
         sc3.getVerticalBar().setIncrement(16);
         sc3.addListener(SWT.Resize, scResizeListener);
       TreeItem item22 = new TreeItem(item2,SWT.NULL);
       item22.setText("緗戝叧閰嶇疆");
         item22.setData("Panel", sc3);
      
       TreeItem[] items = { tree.getItems()[0] };
       tree.setSelection(items);
      
       shell.pack();
   shell.open();
   
   while(!shell.isDisposed()){
    if(!display.readAndDispatch()){
     display.sleep();
    }
   }
   
  display.dispose();
 }
 
 public void setupSC(ScrolledComposite sc) {
  Composite c = (Composite) sc.getContent();
  if (c != null) {
   Point size1 = c.computeSize(sc.getClientArea().width, SWT.DEFAULT);
   Point size = c.computeSize(SWT.DEFAULT, size1.y);
   sc.setMinSize(size);
  }
  sc.getVerticalBar().setPageIncrement(sc.getSize().y);
 }

}

/*----------    鍔ㄤ綔鎺у埗鎺ュ彛浠ュ強瀹炵幇浠g爜 --------*/

public interface ConfigSectionTest {
 public Composite configSectionCreate(final Composite parent);
}

public class ModelConfigSection implements ConfigSectionTest {

 public Composite configSectionCreate(Composite parent) {
  GridData gridData;
  GridLayout layout;
  
  final Composite cMode = new Composite(parent,SWT.WRAP);
  gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL|GridData.VERTICAL_ALIGN_FILL);
  cMode.setLayoutData(gridData);
  layout = new GridLayout();
  layout.numColumns =4;
  layout.marginHeight = 0;
  cMode.setLayout(layout);
  
  
  gridData = new GridData();
  gridData.horizontalSpan = 4;
  final Group gRadio = new Group(cMode, SWT.WRAP);
  gRadio.setText("鐢ㄦ埛鐔熺粌紼嬪害");
  gRadio.setLayoutData(gridData);
  gRadio.setLayout(new RowLayout(SWT.HORIZONTAL));
  
  Button button0 = new Button (gRadio, SWT.RADIO);
  button0.setText("鍒濈駭");
  
  Button button1 = new Button (gRadio, SWT.RADIO);
  button1.setText("涓駭");
  
  Button button2 = new Button (gRadio, SWT.RADIO);
  button2.setText("楂樼駭");
  
  button0.setSelection(true);
  
  gridData = new GridData(GridData.FILL_HORIZONTAL);
     final Label label = new Label(cMode, SWT.WRAP);
     gridData.horizontalSpan = 4;
     label.setLayoutData(gridData);
     label.setText("浠涔堢帺鎰忥紒");
    
    
  return cMode;
 }

}

/*----------- 嫻嬭瘯浠g爜 ----------------*/

public class GridLayoutTest {
 
 public static void main(String[] args){
  
  GridLayoutObject obj = new GridLayoutObject();
  obj.buildLayout();
  
  
 }
}


榪愯緇撴灉錛?br />



zhangxl 2009-08-13 17:27 鍙戣〃璇勮
]]>
SWT-鑿滃崟瀛︿範http://m.tkk7.com/zhanglongsr/articles/291046.htmlzhangxlzhangxlThu, 13 Aug 2009 09:01:00 GMThttp://m.tkk7.com/zhanglongsr/articles/291046.htmlhttp://m.tkk7.com/zhanglongsr/comments/291046.htmlhttp://m.tkk7.com/zhanglongsr/articles/291046.html#Feedback0http://m.tkk7.com/zhanglongsr/comments/commentRss/291046.htmlhttp://m.tkk7.com/zhanglongsr/services/trackbacks/291046.html
  • 浠嬬粛
    鑿滃崟(Menu綾匯丮enuItem綾?鏄父鐢ㄧ殑SWT緇勪歡錛孧enu鏄竴涓彍鍗曟爮錛屼篃鏄竴涓鍣紝鍙互瀹圭撼MenuItem銆侻enu鐨勫鍣ㄤ綔鐢ㄤ富瑕佷綋鐜板湪浠ヤ笅涓や釜鏂歸潰錛?br />
             1.浣滀負鏁翠釜鑿滃崟浣撶郴鐨勫鍣ㄣ?/strong>
             2.浣滀負鍚屼竴鑿滃崟鏍忎笅澶氱駭鑿滃崟鐨勫垎鍓插鍣ㄣ?br />
    鍦ㄤ笅闈㈢殑浠g爜涓偍灝嗚璇嗗埌榪欎竴鐐廣?
  •  

    • 寮忔牱

             Menu寮忔牱
             SWT.BAR   錛?鑿滃崟鏍忥紝鐢ㄤ簬涓昏彍鍗曘?br />          SWT.DROP_DOWN   錛?涓嬫媺鑿滃崟鐢ㄤ簬瀛愯彍鍗曘?br />          SWT.POP_UP   錛?nbsp;  榧犳爣鍙抽敭寮瑰嚭寮忚彍鍗曘?br />
             MenuItem寮忔牱
             SWT.CASCADE   錛?鏈夊瓙鑿滃崟鐨勮彍鍗曢」銆?br />          SWT.CHECK   錛?閫変腑鍚庡墠闈㈠甫灝忛挬銆?br />          SWT.PUSH   錛?nbsp;  鏅氬瀷鑿滃崟欏廣?br />          SWT.RADIO   錛?nbsp;  閫変腑鍚庡墠闈㈠甫涓灝忕偣銆?br />          SWT.SEPERATOR   錛?---- 鍒嗛殧絎?

         婕旂ず浠g爜

    public class MethodUtil {
     
     
      public void buildMenus(){
       
          Display display = new Display();
          Shell shell = new Shell(display);
       
          Label label = new Label(shell,SWT.BORDER|SWT.RIGHT);
          label.setBounds(10, 10, 120, 140);
          label.setText("榪欓噷鏄爣絳?);
          label.setFont(new Font(display,"瀹嬩綋",14,SWT.BOLD));
          label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
       
          //榪欓噷鎸囧畾鏄富鑿滃崟錛屼笖鑿滃崟鏂瑰悜鏄粠鍙沖埌宸︽帓鍒?br />       Menu mainMenu = createMenu(shell, SWT.BAR|SWT.RIGHT_TO_LEFT);
          shell.setMenuBar(mainMenu);
       
          MenuItem fileMenuItem = createMenuItem(mainMenu, SWT.CASCADE, "鏂囦歡&F", null, SWT.CONTROL+'f', true, null);
          Menu fileMenu = createMenu(shell, SWT.DROP_DOWN, fileMenuItem, true);
          MenuItem createItem = createMenuItem(fileMenu, SWT.CASCADE, "鏂板緩&C", null, SWT.CONTROL+'c', true, null);
          Menu createMenu = createMenu(shell, SWT.DROP_DOWN, createItem, true);
       
          /*閲囩敤鍙嶅皠鏈哄埗璋冪敤璋冪敤浜嬩歡澶勭悊鏂規硶*/
          Class[] c = new Class[1];
          Object[] o = new Object[1];
          c[0] = Label.class;
          o[0] = label;
          MenuItem createProject = createMenuItem(createMenu, SWT.PUSH, "欏圭洰\tControl+Shit+N", null, SWT.CONTROL+SWT.SHIFT+'N', true, "changeContent",c,o);
          MenuItem createPackege = this.createMenuItem(createMenu, SWT.PUSH, "鍖?amp;I", null, SWT.CONTROL+'I', true, null);
          MenuItem createClass = this.createMenuItem(createMenu, SWT.PUSH, "綾?amp;K", null, SWT.CONTROL+'K', true, null);
       
          MenuItem open = this.createMenuItem(fileMenu, SWT.PUSH, "鎵撳紑&S", null, SWT.CONTROL+'S', true, null);
          MenuItem exit = this.createMenuItem(fileMenu, SWT.PUSH, "鍏抽棴&S", null, SWT.CONTROL+'M', true, null);
       
          MenuItem help = this.createMenuItem(mainMenu, SWT.PUSH, "甯姪&H", null, SWT.CONTROL+'H', true, null);
       

          shell.pack();
          shell.open();
       
          while(!shell.isDisposed()){
              if(!display.readAndDispatch()){
                  display.sleep();
           }
          }
       
          display.dispose();
         }
      
      public void changeContent(Label label){
       label.setText("鎴戝彉錛屾垜鍙橈紝鎴戝彉鍙樺彉!鍒涘緩宸ョ▼!");
      }

      protected Menu createMenu(Menu parent, boolean enabled) {
          Menu m = new Menu(parent);
          m.setEnabled(enabled);
          return m;
      }
      protected Menu createMenu(MenuItem parent, boolean enabled) {
          Menu m = new Menu(parent);
          m.setEnabled(enabled);
          return m;
      }
      protected Menu createMenu(Shell parent, int style) {
          Menu m = new Menu(parent, style);
          return m;
      }
      protected Menu createMenu(Shell parent, int style,
                                MenuItem container, boolean enabled) {
          Menu m = createMenu(parent, style);
          m.setEnabled(enabled);
          container.setMenu(m);
          return m;
      }
      protected Menu createPopupMenu(Shell shell) {
          Menu m = new Menu(shell, SWT.POP_UP);
          shell.setMenu(m);
          return m;
      }
      protected Menu createPopupMenu(Shell shell, Control owner) {
          Menu m = createPopupMenu(shell);
          owner.setMenu(m);
          return m;
      }
      
      protected MenuItem createMenuItem(Menu parent, int style, String text,
                    Image icon, int accel, boolean enabled,
                    String callback,Class[] c,Object[] o){
       MenuItem mi = new MenuItem(parent, style);
          if (text != null) {
              mi.setText(text);
          }
          if (icon != null) {
              mi.setImage(icon);
          }
          if (accel != -1) {
              mi.setAccelerator(accel);
          }
          mi.setEnabled(enabled);
          if (callback != null) {
              registerCallback(mi, this, callback,c,o);
          }
          return mi;
      }
      protected MenuItem createMenuItem(Menu parent, int style, String text,
                                        Image icon, int accel, boolean enabled,
                                        String callback) {
          MenuItem mi = new MenuItem(parent, style);
          if (text != null) {
              mi.setText(text);
          }
          if (icon != null) {
              mi.setImage(icon);
          }
          if (accel != -1) {
              mi.setAccelerator(accel);
          }
          mi.setEnabled(enabled);
          if (callback != null) {
              registerCallback(mi, this, callback);
          }
          return mi;
      }

      protected void registerCallback(final MenuItem mi,
                 final Object handler,
                 final String handlerName) {
       mi.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
         try {
         Method m = handler.getClass().getMethod(handlerName, null);
         m.invoke(handler, null);
         }
         catch (Exception ex) {
         ex.printStackTrace();
         }
        }
       });
      }
      
      protected void registerCallback(final MenuItem mi,final Object handler,final String handlerName,final Class[] cs,final Object[] params){
       mi.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
         try {
         Method m = handler.getClass().getMethod(handlerName, cs);
         m.invoke(handler, params);
         }
         catch (Exception ex) {
         ex.printStackTrace();
         }
        }
       });
      }
     
    }

    /*璋冪敤嫻嬭瘯*/
    public class MenuTestDesign {
     
     public static void main(String[] arg){
      
      
      MethodUtil u = new MethodUtil();
      u.buildMenus();
      
     }

    }

    榪愯緇撴灉錛?br />




    zhangxl 2009-08-13 17:01 鍙戣〃璇勮
    ]]>
    主站蜘蛛池模板: 免费一级毛片不卡不收费| 99re在线视频免费观看| 无码国模国产在线观看免费| 亚洲福利电影在线观看| 成人免费黄色网址| 久久精品国产亚洲AV蜜臀色欲| 57pao一国产成永久免费| 亚洲国产美女精品久久久久| 欧美大尺寸SUV免费| 亚洲女女女同性video| 四虎永久在线精品免费观看地址 | 亚洲A∨精品一区二区三区下载| 中文字幕影片免费在线观看| 亚洲色成人四虎在线观看| 女人18毛片a级毛片免费| 美女裸免费观看网站| 国产精品亚洲美女久久久| 手机看片国产免费永久| 亚洲日韩图片专区第1页| 在线观看日本免费a∨视频| 亚洲av无码一区二区三区天堂| 亚洲国产天堂久久久久久| 国产啪精品视频网站免费尤物 | 噜噜噜亚洲色成人网站∨| 精品国产无限资源免费观看| 亚洲高清有码中文字| 亚洲不卡AV影片在线播放| 免费a级毛片无码a∨免费软件 | 看成年女人免费午夜视频| 国产综合亚洲专区在线| 亚洲人成在线免费观看| 黄页网址在线免费观看| 亚洲av无码成h人动漫无遮挡 | 国产亚洲漂亮白嫩美女在线| 国产精品亚洲精品日韩已满| 免费看成人AA片无码视频羞羞网| 国产成人精品日本亚洲语音| 亚洲热线99精品视频| 噜噜嘿在线视频免费观看| 91在线免费观看| 亚洲精华国产精华精华液网站|