在同一个项目中同时使用 Eclipse 和 NetBeans

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/174308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 13:20:12  来源:igfitidea点击:

Using both Eclipse and NetBeans on the same project

javaeclipsenetbeans

提问by Milhous

Eclipse is a really great editor, which I prefer to use, but the GUI design tools for Eclipse are lacking. On the other hand, NetBeans works really well for GUI design.

Eclipse 是一个非常棒的编辑器,我更喜欢使用它,但是缺少用于 Eclipse 的 GUI 设计工具。另一方面,NetBeans 非常适合 GUI 设计。

Are there any tips, tricks or pitfalls for using NetBeans for GUI design and Eclipse for everything else on the same project?

将 NetBeans 用于 GUI 设计,将 Eclipse 用于同一项目中的其他所有内容,是否有任何提示、技巧或陷阱?

EDIT:I tried Maven, and it does not seem to work (too complex for my needs).

编辑:我尝试过 Maven,但它似乎不起作用(对于我的需求来说太复杂了)。

采纳答案by Milhous

Create your GUI with Netbeans. copy a Eclipse .project file (like below) into the project folder change the MyProjectName. Open Eclipse and import the project into your workspace, so you can open the projekt from your Eclipse workspace with Netbeans. Now you able to use Netbeans to create and change the GUI and editing the code with Eclipse.

使用 Netbeans 创建您的 GUI。将 Eclipse .project 文件(如下所示)复制到项目文件夹中,更改 MyProjectName。打开 Eclipse 并将项目导入您的工作区,这样您就可以使用 Netbeans 从 Eclipse 工作区打开项目。现在您可以使用 Netbeans 创建和更改 GUI,并使用 Eclipse 编辑代码。

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
 <name>MyProject</name>
 <comment></comment>
 <projects>
 </projects>
 <buildSpec>
  <buildCommand>
   <name>org.eclipse.jdt.core.javabuilder</name>
   <arguments>
   </arguments>
  </buildCommand>
 </buildSpec>
 <natures>
  <nature>org.eclipse.jdt.core.javanature</nature>
 </natures>
</projectDescription>

回答by Tom

MyEclipse offers an integration of the Netbeans GUI editor (Matisse) with Eclipse.

MyEclipse 提供了 Netbeans GUI 编辑器 (Matisse) 与 Eclipse 的集成。

See http://www.myeclipseide.com/module-htmlpages-display-pid-5.html

http://www.myeclipseide.com/module-htmlpages-display-pid-5.html

回答by Andrew Harmel-Law

Echoing @Tom I'd use an external build tool (Maven 2 would be my pick). I've done this on projects before and as long as you don't walk all over Eclipse's .Xxxx files and folders you'll be fine. Then you get the full power of Netbeans (which integrates with Maven 2 reallynicely) or Eclipse and also have the added value of an external build which can also be run by your CI tool. Everybody wins!

回应@Tom 我会使用外部构建工具(Maven 2 将是我的选择)。我以前在项目上做过这个,只要你不走遍 Eclipse 的 .Xxxx 文件和文件夹,你就会没事的。然后,您将获得 Netbeans(它与 Maven 2非常好地集成)或 Eclipse 的全部功能,并且还具有外部构建的附加价值,它也可以由您的 CI 工具运行。每个人都赢了!

回答by Kevin Day

Cloud Garden makes a GUI editor called Jigloothat is quite nice if you are into that sort of thing (and the price is very, very reasonable). If that's all that's missing for you from Eclipse, I'd recommend that you take a look. Netbeans does a ton of stuff with source code that you aren't allowed to edit, etc...

Cloud Garden 制作了一个名为Jigloo的 GUI 编辑器,如果您喜欢这种东西,它非常好(而且价格非常非常合理)。如果您在 Eclipse 中缺少这些,我建议您看一看。Netbeans 使用您不允许编辑的源代码进行了大量操作,等等...

One other thing that I will mention: I have used GUI editors like Matisse and Jigloo for super rapid prototyping. However, within 3 or 4 iterations, I always find myself dropping back to hand coding the layouts. I also find that when I'm doing rapid prototyping, I am almost always more productive when I change the layout manager to absolute and just place components. Once the design starts the gel, implementing the design by hand coding using a good layout manager (I strongly recommend MiG Layout) is pretty easy, and gives much better results.

我要提到的另一件事是:我使用过像 Matisse 和 Jigloo 这样的 GUI 编辑器来进行超快速原型设计。然而,在 3 或 4 次迭代中,我总是发现自己又回到手工编码布局。我还发现,当我进行快速原型制作时,当我将布局管理器更改为绝对布局并仅放置组件时,我的工作效率几乎总是更高。一旦设计开始凝胶,使用一个好的布局管理器(我强烈推荐MiG Layout)通过手工编码实现设计非常简单,并提供更好的结果。

I know that dragging and dropping a GUI layout is really enticing - but MiG Layout is incredibly productive for hand wiring GUIs, and I suspect that almost any developer will be more productive within a week going down that path.

我知道拖放 GUI 布局真的很诱人 - 但 MiG Layout 对于手动布线 GUI 的效率非常高,我怀疑几乎所有开发人员都会在沿着这条路走的一周内提高工作效率。

回答by Kevin Day

import project in netbeans create gui and then again open the project in eclipse

在netbeans中导入项目创建gui然后在eclipse中再次打开项目

it works with no error

它没有错误

回答by Tom

Define your project dependencies with Maven, and use it to generate project configuration files for both Netbeans and Eclipse.

使用 Maven 定义项目依赖项,并使用它为 Netbeans 和 Eclipse 生成项目配置文件。

Try to keep separate classes directories for Eclipse and Netbeans, since Eclipse doesn't like it when external tools touch its classes.

尝试为 Eclipse 和 Netbeans 保留单独的类目录,因为当外部工具接触其类时,Eclipse 不喜欢它。

回答by James Schek

A few gotchas:

一些问题:

  • If you try to use both without any plugins/integration, you must be careful not to edit the regions marked "DO NOT EDIT" as Netbeans will overwrite code in those sections quite frequently.
  • You should use the "Customize..." command to add custom init code for components.
  • Adding/creating new components on a form using Java code will not be reflected in the GUI editor.
  • Developers have to be discouraged from going into the code and adding swing customizations, effectively bypassing the GUI editor.
  • 如果您尝试在没有任何插件/集成的情况下使用两者,则必须小心不要编辑标记为“请勿编辑”的区域,因为 Netbeans 会非常频繁地覆盖这些部分中的代码。
  • 您应该使用“自定义...”命令为组件添加自定义初始化代码。
  • 使用 Java 代码在表单上添加/创建新组件不会反映在 GUI 编辑器中。
  • 必须阻止开发人员进入代码并添加摆动自定义,从而有效地绕过 GUI 编辑器。

Another tip is that you can create Java Beans using Eclipse and drag-and-drop them into the Matisse editor. This allows you to create a custom GUI component or a non-GUI component (models, listeners, etc) and add it to a Matisse form. With listeners and models, you can specify a component to use an instance of your custom listener/model instead of the default behavior. You can also drag-and-drop in custom GUI components and manipulate them like any other GUI widget.

另一个技巧是您可以使用 Eclipse 创建 Java Bean 并将它们拖放到 Matisse 编辑器中。这允许您创建自定义 GUI 组件或非 GUI 组件(模型、侦听器等)并将其添加到 Matisse 表单中。通过侦听器和模型,您可以指定一个组件来使用自定义侦听器/模型的实例而不是默认行为。您还可以拖放自定义 GUI 组件并像操作任何其他 GUI 小部件一样操作它们。

回答by mxro

For me using linked source folders works quite well.

对我来说,使用链接的源文件夹效果很好。

I build the GUIs in independent NetBeans projects - if they need some simple classes or interfaces, I use the "link source" (right click on project in NetBeans, choose properties), to include these in the NetBeans project.

我在独立的 NetBeans 项目中构建 GUI - 如果他们需要一些简单的类或接口,我使用“链接源”(右键单击 NetBeans 中的项目,选择属性),将这些包含在 NetBeans 项目中。

My main projects are in eclipse. Here I again use the link source feature to link to the NetBeans project (right click on project in eclipse, select "build path", then "link source").

我的主要项目在 eclipse 中。这里我再次使用链接源功能链接到 NetBeans 项目(在 eclipse 中右键单击项目,选择“构建路径”,然后选择“链接源”)。

EDIT (Thx to Milhous :) ): in both projects in eclipse and NetBeans further all required JAR files need to be added to the build path (also the libraries added by NetBeans: eg beansbinding-1.2.1.jar, appframework-1.0.3.jar swing-worker-1.1.jar, ...)

编辑(Thx to Milhous :)):在 eclipse 和 NetBeans 的两个项目中,所有需要的 JAR 文件都需要添加到构建路径(还有 NetBeans 添加的库:例如 beansbinding-1.2.1.jar、appframework-1.0。 3.jar swing-worker-1.1.jar, ...)

Now the GUI classes can be reused in eclipse. Also leads to need to have GUI and logic classes quite decoupled, which can be nothing bad.

现在可以在 eclipse 中重用 GUI 类。还导致需要将 GUI 和逻辑类完全分离,这没什么不好。