水平滚动条在CTabItem内部的复合下不起作用

编程入门 行业动态 更新时间:2024-10-28 18:25:39
本文介绍了水平滚动条在CTabItem内部的复合下不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个CtabItem,里面有一个Composite小部件。 然后,我在其中添加了一些组件。 代码如下:-

I have CtabItem inside which, there is a Composite widget. Then, I have added a few components inside it. The code goes like this -

Composite composite = new Composite(tabFolder, SWT.H_SCROLL); tabItem.setControl(composite); Label lblName = new Label(composite, SWT.NONE); lblName.setBounds(10, 28, 55, 15); lblName.setText("Name"); textName = new StyledText(composite, SWT.BORDER); String myText = tree.getSelection()[0].getText(); textName.setText(myText); Point textNamesize = textNameputeSize(SWT.DEFAULT, SWT.DEFAULT); textName.setBounds(76, 28, textNamesize.x, 21); Label lblPath = new Label(composite, SWT.NONE); lblPath.setBounds(10, 83, 55, 15); lblPath.setText("Path"); textPath = new StyledText(composite, SWT.READ_ONLY); textPath.setBackground(new Color(d, 240, 240, 240)); Button saveButton = new Button(composite, SWT.NONE); saveButton.setBounds(456, 134, 75, 25); saveButton.setText("Save"); Button cancelButton = new Button(composite, SWT.NONE); cancelButton.setBounds(548, 134, 75, 25); cancelButton.setText("Cancel");

但是,当我显示选项卡时,会出现滚动条,但是,当我滚动合成时,滚动条会移动,但是滚动条另一侧的元素不会显示任何,知道为什么它不起作用吗?

But, when I am displaying the tab, the scrolls are present, but, when I am scrolling the composite, the scroll bar moves , but the elements on the other side of the scroll are not showing Any, idea why it is not working ?

谢谢!

推荐答案

来自GGrec的 answer 我为您创建了代码段。 我已经将ScrolledComposite与GridLayout一起使用。

from GGrec's answer I created snippet for you. I have used ScrolledComposite with GridLayout. Hope it will make your task easier.

final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandVertical(true); final Composite composite_parent = new Composite(scrolledComposite, SWT.NONE); composite_parent.setLayout(new GridLayout(3, false)); scrolledComposite.setContent(composite_parent); scrolledComposite.setSize(composite_parentputeSize(SWT.DEFAULT, SWT.DEFAULT)); final Composite composite_child = new Composite(composite_parent, SWT.NONE); composite_child.setLayout(new GridLayout(2, false)); final Label lblDefault1 = new Label(composite_child, SWT.NONE); lblDefault1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblDefault1.setText("Name"); final StyledText textStyled = new StyledText(composite_child, SWT.NONE); textStyled.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); Label lblNewLabel_1 = new Label(composite_child, SWT.NONE); lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblNewLabel_1.setText("Path"); text = new Text(composite_child, SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); scrolledComposite.setMinSize(composite_parentputeSize(SWT.DEFAULT, SWT.DEFAULT));

更多推荐

水平滚动条在CTabItem内部的复合下不起作用

本文发布于:2023-11-03 01:01:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1553857.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:滚动条   不起作用   水平   CTabItem

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!