java idea ui库,IntelliJ IDEA的13 UI设计师和自动摇篮建设

I've used the Intellij UI Designer to create forms for a project. Everything works fine when I'm building with idea as it handles compiling the forms for me, but as we recently switched to using Gradle for building it hasn't been possible to produce an executable jar file yet.

My google-fu has led me to several posts that explains that an ant script is needed to compile (eg link, link2, link3 ,and the one i ended on following: link4)

My project is a multi-module setup.

root build.gradle

subprojects {

apply plugin: 'java'

apply plugin: 'idea'

repositories {

mavenCentral()

}

}

supproject build.gradle

apply plugin:'application'

mainClassName = "dk.OfferFileEditor.OfferFileEditorProgram"

configurations {

antTask

}

dependencies {

compile 'org.json:json:20140107'

compile project(":Shared:HasOffers Api")

//dependencies for java2c

antTask files('../../lib/javac2-13.1.1.jar', '../../lib/asm4-all-13.1.1-idea.jar', '../../lib/forms_rt-13.1.1.jar')

antTask group: 'org.jdom', name: 'jdom', version: '1.1'

}

task compileJava(overwrite: true, dependsOn: configurations.compile.getTaskDependencyFromProjectDependency(true, 'jar')) {

doLast {

println 'using java2c to compile'

project.sourceSets.main.output.classesDir.mkdirs()

ant.taskdef name: 'javac2', classname: 'com.intellij.ant.Javac2', classpath: configurations.antTask.asPath

ant.javac2 srcdir: project.sourceSets.main.java.srcDirs.join(':'),

classpath: project.sourceSets.main.compileClasspath.asPath,

destdir: project.sourceSets.main.output.classesDir,

source: sourceCompatibility,

target: targetCompatibility,

includeAntRuntime: false

}

}

But even though the compilation is successfull, a Nullpointer exception is thrown the first time I try to access one of the fields the UI Designer created. So something is not being compiled correctly.

I'm probably missing some setting, but after unsuccesfully pouring several hours into forums and google I still haven't found any solution.

解决方案

So I made this a lot more complicated than needs be.

To make it work you need to change two things in your project.

A setting in IDEA 13.1.5

Settings -> GUI Designer -> Generate GUI into: Java source code

This makes IntelliJ IDEA add 3 methods into the bottom of your forms:

$$$setupUI$$$()

$$$setupUI$$$()

$$$getRootComponent$$$()

If they are missing try recompiling your project after you change the setting.

Add the missing classes

Intellij has a jar called forms_rt.jar, and I found mine in {IntelliJ IDEA Root}\lib. And renamed it to "forms_rt-13.1.1.jar"

This needs to be included during compile time to your project. If you are using Gradle as I did you could copy it to {project root}/lib and add a flatfile repository like so:

repositories {

mavenCentral()

flatDir dirs: "${rootDir}/lib"

}

After that you need to include it in your project gradle file:

dependencies {

compile name: 'forms_rt', version: '13.1.1'

}

After that it should be possible to build it both in IntelliJ IDEA and Gradle.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值