简体   繁体   English

我如何使用eclipse构建GUI? (我想只使用swing / awt而没有其他包)

[英]How can I use eclipse to build a GUI? (I want to use only swing/awt and no other packages)

I usually write java code using a simple text editor and .bat files to compile and run. 我通常使用简单的文本编辑器和.bat文件编写java代码来编译和运行。 I'm not used to IDEs like Eclipse or Netbeans and as a result every GUI I've made so far has been written by hand. 我不习惯像Eclipse或Netbeans这样的IDE,因此我到目前为止制作的每个GUI都是手工编写的。

Questions: 问题:

  • Can I use eclipse to build a GUI easily (eg drag-drop features)? 我可以使用eclipse轻松构建GUI(例如拖放功能)吗?

  • Can this generated code use only the basic java packages (swing, awt) and not any other package provided by the IDE? 这个生成的代码是否只使用基本的java包(swing,awt)而不是IDE提供的任何其他包?

I'm saying this because -correct me if I'm wrong- from what I have read so far, I understand that Eclipse and other IDEs use their own packages (to achieve better layouts for example). 我这样说是因为 - 如果我错了,请纠正我 - 从我到目前为止所读到的内容来看,我理解Eclipse和其他IDE使用自己的包(例如,实现更好的布局)。 I would like to avoid this dependency and if possible copy-paste the code generated by Eclipse and then work in the simple way I'm used to. 我想避免这种依赖,如果可能的话,复制粘贴Eclipse生成的代码,然后以我习惯的简单方式工作。

Thanks in advance. 提前致谢。

[edit] [编辑]
Having tried it for a couple of days, I can now say that WindowsBuilder is exactly what I was looking for. 经过几天的尝试,我现在可以说WindowsBuilder正是我想要的。 Thank you for all your replies. 谢谢你的回复。

Eclipse uses the Standard Widget Toolkit (SWT, not included in JRE by default), Netbeans uses Swing (included). Eclipse使用Standard Widget Toolkit(SWT,默认情况下不包含在JRE中),Netbeans使用Swing(包含)。
Since recent Eclipse versions, it includes WindowBuilder to create Swing or SWT via drag'n'drop. 从最近的Eclipse版本开始,它包含WindowBuilder以通过拖放创建Swing或SWT。 WindowBuilder is even bidirectional, so code generation is supported as well as reflecting hand-made changes. WindowBuilder甚至是双向的,因此支持代码生成以及反映手工更改。 It don't know if Netbeans includes this feature, too. 它不知道Netbeans是否也包含此功能。 In 'New' dialog of Eclipse you find everything you need under the WindowBuilder category. 在Eclipse的“新建”对话框中,您可以在WindowBuilder类别下找到所需的一切。

Can I use eclipse to build a GUI easily (eg drag-drop features)? 我可以使用eclipse轻松构建GUI(例如拖放功能)吗?

Yes, go to the Marketplace and pull in WindowsBuilder; 是的,转到市场并拉入WindowsBuilder; it supports bi-directional GUI drag-n-drop / direct-code editing. 它支持双向GUI拖放/直接代码编辑。

Can this generated code use only the basic java packages (swing, awt) and not any other package provided by the IDE? 这个生成的代码是否只使用基本的java包(swing,awt)而不是IDE提供的任何其他包?

The code generated by the Swing Design tool is strictly Swing/AWT based. Swing Design工具生成的代码严格基于Swing / AWT。

It does offer design tools for SWT and GWT as well. 它确实为SWT和GWT提供设计工具。

Yes , You can use the feature of drag and Drop in java by going through these few Steps: 是的,您可以通过以下几个步骤使用java中的拖放功能:

HelpEclipse MarketPlaceWindowBuilder(Install) 帮助Eclipse MarketPlaceWindowBuilder(安装)

If you want to create Drag n Drop Swing GUI, you should try Netbeans. 如果你想创建Drag n Drop Swing GUI,你应该试试Netbeans。 Eclipse may have a plugin but i usually find netbeans very good in GUI and it is also recommended by Sun for making Swing/AWT GUI Eclipse可能有一个插件,但我通常会发现netbeans在GUI中非常好,并且Sun也推荐它用于制作Swing / AWT GUI

I haven't seen such in Eclipse. 我在Eclipse中没见过这样的东西。 In Netbeans you can of course. 在Netbeans中你当然可以。 But I am warning you! 但我警告你! Create the GUI by hand. 手动创建GUI。 Netbeans is using GroupLayout to build drag and drop GUI, and that's a nightmare when you look at it!!! Netbeans正在使用GroupLayout来构建拖放GUI,当你看到它时,这是一场噩梦! If eclipse has the same function, don't expect more than this!! 如果eclipse具有相同的功能,不要指望超过这个!! Apart from that, not like .NET, most Java developers create everything by hand (Yes, real programming..That's why most say Java is hard). 除此之外,不像.NET,大多数Java开发人员手工创建所有东西(是的,真正的编程......这就是为什么大多数人说Java很难)。 So, it is better if you can get used to it :) 所以,如果你能习惯它会更好:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM