2009-09-27 72 views
0

當試圖將PApplet添加到SWT中時出現問題,當它應該呈現PApplet時,會出現一個空窗口。即PApplet本身工作,但不在SWT窗口。如何在SWT中添加處理PApplet

我認爲只需在框架中添加PApplet應該首先使用Eclipse中的SWT教程代碼。顯然這並不容易。這裏是我的代碼,其中MyPApplet是一個定製PApplet

public static void main(String[] args) { 
    Display display = new Display(); 
    Shell shell = new Shell(display); 
    Composite composite = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND); 
    Frame frame = SWT_AWT.new_Frame(composite); 
    PApplet pApplet = new MyPApplet(); 
    frame.add(pApplet); 
    shell.open(); 
    while (!shell.isDisposed()) { 
     if (!display.readAndDispatch()) display.sleep(); 
    } 
    display.dispose(); 
} 

我缺少的東西?

+0

叫我白癡......什麼是PApplet? – andyczerwonka 2009-10-28 23:12:46

+0

@arcticpenguin:PApplet是一個類processing.org用作窗口/小程序框架,它是java的Applet類的子類 – Spoike 2009-10-29 09:38:47

+0

@Spoike你有沒有找到一個解決方案? – RoflcoptrException 2012-04-07 22:45:59

回答

1

我認爲有一個替代方法來實現這一點。 使用Swing Component作爲適配器,其中包括: 將PApplet添加到JComponent中,例如JInternalFrame,然後將此JComponent嵌入到SWT Composite中。

我做的一些做法,並能正常工作..

,也是我在博客中對這個話題的一些總結: http://blog.csdn.net/godoorsun/article/details/6747589

(順便說一句,這篇文章是寫在中國:(也許你可以通過谷歌翻譯閱讀,但該文章的示例代碼很容易理解)