`
superheizai
  • 浏览: 64329 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

ScrolledComposite的使用

 
阅读更多
在我们的系统中,使用的是jface的dialog。
在系统中,需要根据对话框的大小使用滚动条来实现图片的展现。根据别的同学的学习成果和自己的总结,完成了自己的界面,把主要的实现在这里写下,方便自己和别的同学:)
protected Control createDialogArea(Composite parent) {

		     ScrolledComposite panel = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL|SWT.H_SCROLL);  
//		     这句话控制的是,要不要在显示不了 图片的大小的时候显示出两个方向的滚动条
//		     panel.setLayoutData(new GridData(GridData.FILL_VERTICAL|GridData.FILL_HORIZONTAL));  
		     panel.setLayoutData(new GridData(GridData.FILL_BOTH));  
//		     注释掉下面这句话,不是所有时候都要使用滚动条。如果不注释掉的话,在不需要的时候,滚动条会灰掉,而不是隐藏。
//		     panel.setAlwaysShowScrollBars(true);  		     
//		两个set保证了显示这个滚动内容     
		     panel.setExpandHorizontal(true);  
		     panel.setExpandVertical(true);  
		    panel.setLayout(new GridLayout(1, false));  
		      
	        Composite subPanel = new Composite(panel, SWT.BORDER);  
	       subPanel.setLayoutData(new GridData(GridData.FILL_BOTH));  
		    subPanel.setLayout(new GridLayout(1, true));  
		  
		    
		     panel.setContent(subPanel); 
		
      try{
      Image img=taskAllocateAction.getImg(taskID);
      
      subPanel.setBackgroundImage(img);
       //       根据图片大小调整框的大小
           panel.setMinHeight(img.getBounds().height);  
	     panel.setMinWidth(img.getBounds().width);
      }catch(Exception ex){
    	  ex.printStackTrace();
      }
      return panel;	
	}
	
分享到:
评论
1 楼 zxjlwt 2015-10-27  
学习了。
http://surenpi.com

相关推荐

    ScrolledComposite自动出现滚动条

    ScrolledComposite自动出现最适合大小的滚动条代码

    simple.zip

    swt常有控件入门demo Button1.java Canvas1.java ...ScrolledComposite1.java SimpleEditor1.java SimpleEditor2.java Slider1.java TabFolder1.java ToolBarExample.java ToolBarMangerExample.java

    Eclipse_Swt_Jface_核心应用_部分19

    6.7 滚动面板(ScrolledComposite) 95 6.7.1 设置滚动条的样式 96 6.7.2 滚动面板的其他方法 97 6.8 本章小结 97 第7章 SWT布局管理器 98 7.1 布局管理器概述 98 7.1.1 绝对定位 98 7.1.2 托管定位 ...

    org.eclipse.swt.win32

    org.eclipse.swt.custom.ScrolledComposite.class org.eclipse.swt.custom.ScrolledCompositeLayout.class org.eclipse.swt.custom.StackLayout.class org.eclipse.swt.custom.StyleRange.class org.eclipse.swt....

Global site tag (gtag.js) - Google Analytics