English 中文(简体)
表格和两个按钮的剪贴布局
原标题:Eclipse layout for table and two buttons
  • 时间:2012-05-22 19:43:35
  •  标签:
  • eclipse
  • swt

我想给日圆编辑写一张表格 遇到一些问题

想法是有一个包含两个部分的页面 - 左手部分包含一个表格和两个按钮。 表格应该与该部分的顶部排成一行, 然后向下延伸。 我希望该按钮坐在该部分的表右侧, 在另一部分下每个按钮, 并且让它们与表格的顶部对齐 。

有谁知道我需要为GridLayout什么设置来做这个工作吗?

最接近我最接近的就是页面底部的第二个按钮

以下是目前为止我代码的节录:

Section section = toolkit.createSection(sashForm, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.NO_TITLE_FOCUS_BOX);
section.setText("All Items");

Composite client = toolkit.createComposite(section);
section.setClient(client);

client.setLayout(new GridLayout(2, false));

Table table = toolkit.createTable(client, SWT.NULL);
table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));

TableViewer viewer = new TableViewer(table);

Button addButton = toolkit.createButton(client, "Add", SWT.PUSH);
addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));

Button removeButton = toolkit.createButton(client, "Remove", SWT.PUSH);
removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
最佳回答

请查看",http://www.eclipse.org/articles/article.php?files=Article-Organde-Layouts/index.html" rel=“nofollow”>SWT布局教程 它在GridLayout上有一个很好的部分。

您会想要使用 GridData. verticalSpan 来使表格覆盖两行。 这应该将两个按钮放在右侧。 但是, 按钮会采取与表格相同的空间, 而这可能不是您想要的, 所以您可能需要给表格提供垂直大小提示 。

问题回答

暂无回答




相关问题
In Eclipse, why doesn t "Show In" appear for non-Java files?

If I have a *java file open, I can right click on the source, scroll down to "Show In (Alt-Shift-W)", and select Navigator. If I have an *xml, *jsp, or pretty much anything besides a Java source ...

Eclipse: Hover broken in debug perspective

Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable s value. Instead, hover behaves as if I were in normal Java perspective: alt text http://...

Eclipse smart quotes - like in Textmate

Happy Friday — Does anyone know if eclipse has the notion of smart quotes like Textmate. The way it works is to select some words and quote them by simply hitting the " key? I m a newbie here so be ...

Indentation guide for the eclipse editor

Is there a setting or plugin for eclipse that can show indentation guides in the editor? Something like the Codekana plugin for visual studio (not so fancy is also OK). Important that it works with ...

Adding jar from Eclipse plugin runtime tab

I want to add .jar files for plugin from the Runtime tab of manifest file. When I use the Add... button, I can see only sub-directories of the plugin project. So if I want to add same .jar file to ...

How to copy multiple projects into single folder in eclipse

I have two projects, Project1 and Project2. Now i want to copy this projects into eclipse workspace but i want these projects to be in a single folder like below. Eclipse Workspace -> Project -> ...

Java: Finding out what is using all the memory

I have a java application that runs out of memory, but I have no idea which code is allocating the memory. Is there an application with which I can check this? I use Eclipse.

热门标签