[英]Minimum size of JFace application window
我剛開始使用JFace / SWT進行GUI編程。 在使用普通的SWT窗口之前( http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.wb.ercp.doc.user%2Fhtml%2Fwizards%2FeRCP%2Fapplication_window.html )今天,我第一次嘗試了“ JFace應用程序窗口”。
現在,我想設置此窗口的最小大小。在SWT中,它與
shell.setMinimumSize(100,100)
但是在我的org.eclipse.jface.window.ApplicationWindow中沒有這樣的方法。
我試過了
this.createShell().setMinimumSize(100, 100);
(我的實現“公共類MainView擴展了ApplicationWindow {”)
但這不起作用。
this.getShell()
返回null。
順便說一句,我現在在gernal中搜索了有關JFace的很好的文檔,尤其是在Application Window中。 但是我找不到任何真正好的和廣泛的東西。
SWT中的文檔(尤其是JFace)非常令人沮喪。.太糟糕了,因為其中有不錯的功能。
你有什么經驗?
覆蓋configureShell
方法並在此處設置最小大小:
@Override
protected void configureShell(Shell newShell)
{
super.configureShell(newShell);
newShell.setMinimumSize(100, 100);
}
從createShell方法的文檔中可以看到,它創建了一個新的shell。 您需要使用窗口的現有/創建的外殼。
您可以從應用程序的父組合中獲取它。 請在以下代碼段中查看createContents方法:
package helloproject;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
public class HelloWorld extends ApplicationWindow {
public HelloWorld() {
super(null);
}
/**
* Runs the application
*/
public void run() {
setBlockOnOpen(true);
open();
Display.getCurrent().dispose();
}
protected Control createContents(Composite parent) {
// Create a Hello, World label
Label label = new Label(parent, SWT.CENTER);
label.setText("Hello, World");
// Set the minimum size
parent.getShell().setMinimumSize(200, 200);
return label;
}
public static void main(String[] args) {
new HelloWorld().run();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.