简体   繁体   English

Scrollable View Eclipse插件

[英]Scrollable View Eclipse Plugin

I'm currently redoing from the start a school project which is basically a view with a label in it. 我目前正在从头开始重做一个学校项目,该项目基本上是一个带有标签的视图。

Right now all I want to do is showing some text in the label and making the view scrollable if the text is too long. 现在,我要做的就是在标签中显示一些文本,如果文本太长,则使视图可滚动。 I manage to make the view scrollable by giving a size to the label, but if the text is to long the scroll bar wont help see it entirely. 我设法通过给标签加上大小来使视图可滚动,但是如果文本太长,滚动条将无法完全看到它。

This is the code I have so far (it's just the createPartControl function, tell me if you need more): 这是我到目前为止的代码(只是createPartControl函数,告诉我是否需要更多代码):

public void createPartControl(Composite parent) {

ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);

aLabel = new Label(sc, SWT.H_SCROLL | SWT.V_SCROLL);
aLabel.setBackground(getSite().getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));
aLabel.setSize(400,400);

sc.setContent(aLabel);
sc.setMinSize(aLabel.computeSize(aLabel.getBounds().width, aLabel.getBounds().height));
sc.setExpandVertical(true);
sc.setExpandHorizontal(true);  
}

Create label with SWT.WRAP style constant, instead of SWT.H_SCROLL | SWT.V_SCROLL 使用SWT.WRAP样式常量而不是SWT.H_SCROLL | SWT.V_SCROLL创建标签SWT.H_SCROLL | SWT.V_SCROLL SWT.H_SCROLL | SWT.V_SCROLL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM