我想使用swt来制作GUI,但我不想使用eclipse来编程。无论如何要做到这一点。另外,是否有任何用于swt的GUI设计器都不是eclipse插件。
答案 0 :(得分:5)
当然可以独立于Eclipse-RCP平台使用SWT。你只需要有适当的罐子。查看这些示例http://www.eclipse.org/swt/snippets/。例如:
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
public class Snippet169 {
public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell (display);
shell.setLayout (new FillLayout ());
Listener listener = new Listener () {
public void handleEvent (Event e) {
Control [] children = shell.getChildren ();
for (int i=0; i<children.length; i++) {
Control child = children [i];
if (e.widget != child && child instanceof Button && (child.getStyle () & SWT.TOGGLE) != 0) {
((Button) child).setSelection (false);
}
}
((Button) e.widget).setSelection (true);
}
};
for (int i=0; i<20; i++) {
Button button = new Button (shell, SWT.TOGGLE);
button.setText ("B" + i);
button.addListener (SWT.Selection, listener);
if (i == 0) button.setSelection (true);
}
shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
此外,SWT设计师并不局限于Eclipse插件,只是google找到合适的插件。 Eclipse的SWT设计器示例(但不仅适用于Eclipse插件):http://www.eclipse.org/windowbuilder/
答案 1 :(得分:0)
您必须将Eclipse安装到您的计算机上,但您可以将SWT JAR文件从Eclipse复制到其他编辑器的类路径中。
我认为没有任何非Eclipse SWT GUI设计师。
答案 2 :(得分:0)
SWT独立于日食。您可以将它用于基于RCP / SWT的应用程序,也可以用作基于J2SE / SWT的应用程序。在第一种情况下,您将使用Eclipse Equinox OSGi并将依赖项添加到org.eclipse.ui * ...,在第二种情况下,您需要下载特定于平台的SWT * .jar库并将其放入J2SE应用程序的类路径中。 / p>
我现在更喜欢RCP / SWT开发,因为它更易于插入和模块化,因为它使用了J2SE。
我更喜欢Eclipse IDE而不是其他Eclipse IDE,因为我只是开始使用Eclipse(即使我也尝试过Netbeans或InteliJ) - 但这是每个开发人员选择使用IDE的问题。
在玩SWT&amp; JFace即使没有WindowBuilder也可以创建GUI - &gt;我确实使用WindowBuilder但是在生成代码之后,我总是自己更改代码,但它当然是很好的工具。