No Scroll on View in Eclipse RCP

☆樱花仙子☆ 提交于 2019-12-11 15:05:58

问题


I am supposed to create a scroll bar in my Eclipse RCP view and I referred to the ScrolledComposite javadoc and taking help from this.

private void createComposite2(final Composite parent,final String text, int compositeNumber)
{
    final ScrolledComposite rightScrolled = new ScrolledComposite(parent, SWT.V_SCROLL|SWT.H_SCROLL|SWT.BORDER);
    group=GUIToolkit.newGroup(rightScrolled, SWT.NONE, text, null);
    rightScrolled.setContent(group);
    group.setLayout(new FillLayout());      
    rightScrolled.setExpandHorizontal(true);
    rightScrolled.setExpandVertical(true);  
    group.setSize(group.computeSize(SWT.DEFAULT, SWT.DEFAULT));         
    group.setBackground(white);
    createPartControl(group,compositeNumber);
}

But instead the scroll is absent. Can anybody tell me what exactly is the problem? In one of the online resources I saw addControlListner. Will that help? If yes, how can I use it?

After some research and hit and trial, i came up with this code,

private void createComposite2(final Composite parent,final String text, int compositeNumber)
{
  final ScrolledComposite rightScrolled = new ScrolledComposite(parent, SWT.V_SCROLL|SWT.H_SCROLL);
  group=GUIToolkit.newGroup(rightScrolled, SWT.NONE, text, null);
  rightScrolled.setContent(group);
  rightScrolled.setExpandHorizontal(true);
  rightScrolled.setExpandVertical(true);
  rightScrolled.addControlListener(new ControlAdapter() {
  public void controlResized(ControlEvent e) {
  org.eclipse.swt.graphics.Rectangle r = rightScrolled.getClientArea();
  rightScrolled.setMinSize(group.computeSize(r.width, SWT.DEFAULT));
  }
  });
  group.setLayout(new FillLayout());
  group.setBackground(white);
  createPartControl(group,compositeNumber);
 }

which resulted in scroll coming but it would not readjust to show the window. Have a look at the first composite with name SOAD. It's the normal size.

and now this is when i push it on left side, the scroll should have been activated, and it is not... It is cropping the content.

How do i fix this

来源:https://stackoverflow.com/questions/29675709/no-scroll-on-view-in-eclipse-rcp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!