1
A
回答
3
因爲你沒有說過你在何時,在哪裏以及如何設置複合尺寸,所以我假設你正在設置一個事件的大小,以及setSize
適合我。
我在Win7,eclipse 4.2和JDK 1.6_b30上。參見示例代碼:
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
public class Test
{
public static void main(String[] args) throws Exception
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
TabFolder folder = new TabFolder(shell, SWT.TOP);
folder.setLayout(new GridLayout());
folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TabItem item = new TabItem(folder, SWT.NONE);
item.setText("Tab 1");
final Composite composite = new Composite(folder, SWT.BORDER);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Text text = new Text(composite, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
text.setText("Tab 1");
Button b = new Button(composite, SWT.PUSH);
b.setText("Press");
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
composite.setSize(23, 43);
}
});
item.setControl(composite);
shell.setSize(300, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Before Pressing the Button
After Pressing the Button
雖然有趕上!只要您調整應用程序的大小,複合材料就會回到的原始尺寸!
也有 可能是一個問題,如果你不使用設置大小的任何事件(可能在SWT標籤文件夾了一些bug或功能)。非侵入性的
hack
(不需要任何用戶交互)是使用
PaintListener
。請參見下面的代碼:
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
public class Test
{
public static void main(String[] args) throws Exception
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
final TabFolder folder = new TabFolder(shell, SWT.TOP);
folder.setLayout(new GridLayout());
folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TabItem item = new TabItem(folder, SWT.NONE);
item.setText("Tab 1");
final Composite composite = new Composite(folder, SWT.BORDER);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Text text = new Text(composite, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
text.setText("Tab 1");
folder.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
composite.setSize(23, 43);
}
});
item.setControl(composite);
shell.setSize(300, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
的PaintListener
解決方案是不是一個非常優雅的解決方案,但它適合我的發展環境。
相關問題
- 1. SWT的JFace:SelectionProvider在TabFolder中
- 2. SWT TabFolder懶加載
- 3. SWT Composite Transform
- 4. 在SWT中獲取活動標籤TabFolder
- 5. 如何在TabFolder中嵌入SWT TableViewer?
- 6. 將TabFolder大小內容的ScrolledCompsite設置爲零
- 7. SWT TabFolder垂直方向
- 8. SWT Composite出現在右邊
- 9. SWT - 你如何重新設置一個位於另一個複合材料內的Composite的大小/設置大小?
- 10. SWT Composite需要3.6.1中的包()
- 11. 在SWT中設置顏色
- 12. SWT TabFolder有什麼替代方案?
- 13. 設置Java SWT shell窗口內部區域的大小
- 14. SWT設置外殼大小以跨越多個顯示器
- 15. SWT - 如何更改TabFolder中現有TabItem的順序
- 16. 如何在樹中設置treeItems的最大級別(SWT)?
- 17. 更改SWT中的字體大小
- 18. 在JToolbar中設置JLabel的大小
- 19. 設置JTextField在JTable中的大小
- 20. 在ListView中設置文本的大小
- 21. SWT調整大小錯誤
- 22. 設置大小UIImageView
- 23. 設置UIImageView大小?
- 24. 如何設置焦點SWT TableItem
- 25. 如何在行中設置SWT列表的高度?
- 26. 設置SharedObject最大大小
- 27. Android,在TableLayout中設置列大小
- 28. 在gridLayout中設置JButton大小
- 29. 在OSMF中設置視頻大小
- 30. 在vosao中設置圖像大小