如何将intellij中的普通java项目转换为JavaFx项目 [英] How to convert a normal java project in intellij into a JavaFx project

查看:1094
本文介绍了如何将intellij中的普通java项目转换为JavaFx项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用普通的java项目(gradle项目),并希望将其转换为JavaFx项目,而无需将现有源重新导入到新的Javafx项目中。有没有办法实现这个目标?

I am currently using a normal java project (gradle project) and want to convert this into a JavaFx project without having to reimport the existing sources into a new Javafx project. Is there any way to achieve this?

推荐答案

没有什么可以转换的。

我认为普通Java项目和JavaFX项目之间的理念没有任何区别。

I don't believe there is any difference in Idea between a "normal" Java project and a JavaFX project.

当然,在Idea 12.x +那里是一个可用于创建新JavaFX项目的向导。但我认为它所做的只是创建一个示例hello world应用程序 - 在初始创建之后,项目的工作方式与任何其他Java项目没有任何不同。

Sure, in Idea 12.x+ there is a wizard you can use to create a new JavaFX project. But I think that all it does is create a sample hello world application - after initial creation, the way the project works is not any different than any other Java project.

这就是它应该是的样子,JavaFX只是Java。 Oracle不会在他们的发行版中区分JavaFX和Java,也不应该在他们的项目类型中使用IDE。

And this is how it should be, JavaFX is just Java. Oracle doesn't differentiate between JavaFX and Java in their distribution, and neither should IDEs in their project types.

我相信,在这种情况下,即使我错了,我是对的,如果我错了,这并不重要。

I believe, in this case, even if I'm wrong, that I am right enough that it doesn't really matter if I'm wrong.

更新

所以我错了很重要: - )

So I was wrong enough that it matters :-)

使用Idea 13.1.4,如果我使用<$ c $创建一个新项目c>文件|新项目| Java ,有以下资源设置(文件|设置|编译器):

Using Idea 13.1.4, if I create a new project using File | New Project | Java, there are the following resource settings (File | Settings | Compiler):

?*.properties;?*.xml;?*.gif;?*.png;?*.jpeg;?*.jpg;?*.html;?*.dtd;?*.tld;?*.ftl

也就是说,项目的资源只是设置为仅复制特定文件类型。因此,您可以通过为fxml和css添加资源复制支持来修改它以获取某些JavaFX项目中所需的其他文件类型;即附加;?*。fxml;?*。css

That is, the resources for the project are just set to copy only specific file types. So you could modify it to get the additional file types required in some JavaFX projects by adding resource copying support for fxml and css; i.e, appending ;?*.fxml;?*.css.

有趣的是,如果你创建使用文件|的新项目新项目| JavaFX ,有以下资源设置:

The interesting part is that if you create a new project using File | New Project | JavaFX, there are the following resource settings:

!?*.java;!?*.form;!?*.class;!?*.groovy;!?*.scala;!?*.flex;!?*.kt;!?*.clj

基本上,它复制的不是源文件,一种文件黑名单集而不是其他项目创建模板使用的文件白名单集。真的很奇怪......无论如何,资源集是用户可配置的,所以你可以根据需要修改它们,一旦你这样做,你就不应该有任何问题(我相信,但我以前错了;-)

Essentially, it's copying everything which not a source file, a kind of file blacklist set rather than a file whitelist set as is used by other project creation templates. Really weird... Anyway, the resource sets are user configurable, so you can modify them as you see fit and once you do so, you shouldn't have any issues (I believe, but I've been wrong before ;-)

建议 - 将第三方构建工具与IDE结合使用

你最好不要使用像Gradle或Maven这样的第三方工具。 Idea适用于这些外部构建工具(和其他)。使用第三方工具的优点是:

You might be better off basing your build off of a 3rd party tool such as Gradle or Maven. Idea works really well with both these external build tools (and others). The advantages of using a 3rd party tool is:


  1. 使用这些工具的项目遵循约束,其中资源放置在特定资源文件夹中在该文件夹中被视为要在构建输出中打包的资源。因此,那里的混乱更少。

  2. 由此产生的项目更易于使用,更容易被其他未使用Idea的开发人员使用。

  3. 项目可以通过连续轻松构建集成构建系统,如Jenkins。

  4. Gradle和Maven都有特定于JavaFX的插件,为打包JavaFX应用程序提供了额外的支持。

  1. Projects with those tools follow a convention where resources are placed in a specific resource folder and everything in that folder is treated as a resource to be packaged in your build output. So there is less confusion there.
  2. The resultant projects are more portable and easier to use by other developers who may not be using Idea.
  3. The projects can be built easily by continuous integration build systems like Jenkins.
  4. Both Gradle and Maven have JavaFX specific plugins which provide additional support for packaging JavaFX applications.

当然,使用第三方构建工具的缺点是学习它们的复杂性(以及许多怪癖),因为有时它们可​​能是相当野兽。因此,我认为这是一个权衡 - 小型的个人探索性项目不需要它们,您打算与他人分享的大型项目或项目可以从使用此类工具中获益。

Of course, the disadvantage of using a 3rd party build tool, is the complexity (and many quirks) of learning them as sometimes they can be quite the beast. So I think it's a bit of a tradeoff - small, personal exploratory projects don't need them, larger projects or projects you intend to share with others benefit from using such tools.

这篇关于如何将intellij中的普通java项目转换为JavaFx项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆