Comments (21)
I'm assuming you get this example to work in IDEA when you remove the main method, right? Your problem is that you want to override the startup sequence somehow?
EDIT: If you created a Kotlin
run configuration in IDEA, it will not recognize JavaFX applications. If you choose the normal Application
type, everything works fine.
First of all, your main method is not static, it's just a method sitting in a class, so Java doesn't recognize it as an application entry point.
Normally you declare Kotlin main methods as a package level construct, ie. outside your App class:
fun main(args: Array<String>) {
Application.launch(MainApp::class.java, *args)
}
You would then tell IDEA that your main class is called MainAppKt
.
But why do you need to provide the main method? Doesn't IntelliJ recognise MainApp
as runnable? Without a main method you should simply specify MainApp
and it should work.
from tornadofx.
@thomasnield see my edit above - maybe you chose the Kotlin
run configuration instead of the one called Application
?
from tornadofx.
I created a page in the Wiki where I mention this IDEA specific caveat :)
https://github.com/edvin/tornadofx/wiki/Application-Startup
from tornadofx.
Perfect! Yeah I was just trying to get it to run. Creating the IDEA Application configuration did the trick. Thanks a lot and I look forward to playing with this library.
from tornadofx.
Nice :) Let me know if you need any further help :)
from tornadofx.
Thank you sir, will do!
from tornadofx.
Yeah, main()
needs to be on file level (i.e. within FooKt
for the file foo.kt
). Luckily Kotlin allows multiple main
s within a package, so it allows multiple Application
s.
By the way: IDEA treats JavaFX Application
s in Java to allow to omit the main
method. I opened a feature request, to have the same for Kotlin: https://youtrack.jetbrains.com/issue/KT-8773
from tornadofx.
Thanks, @hastebrot - that's what I noticed also. I voted for KT-8773 as well :) Good to get the ball rolling on that.
from tornadofx.
@hastebrot I just started to figure that out regarding the file level as well as the omission of the main()
method. Thanks for filing that as it would be convenient.
from tornadofx.
I voted as well.
from tornadofx.
I hate to tangent, but did I build this 3-tabbed pane optimally? Even if some builders could be added, really like the succinct nature of this already.
class MainApp : App() {
override val primaryView = MainView::class
class MainView : View() {
override val root = with(HBox()) {
this += with(TabPane()) {
with (tabs) {
add(Tab("Tab 1"))
add(Tab("Tab 2"))
add(Tab("Tab 3"))
}
this
}
this += with (VBox()) {
this += Button("Bttn 1")
this += Button("Bttn 2")
this
}
this
}
}
}
from tornadofx.
At least the second element of the HBox
could be created like this:
class Main : View() {
override val root = StackPane()
init {
with(root) {
setPrefSize(500.0, 500.0)
hbox {
vbox {
button("Bttn 1")
button("Bttn 2")
}
}
}
}
}
from tornadofx.
I wonder why IntelliJ doesn't suggest me tabpane()
and tab()
from tornadofx/Builders.kt
.
from tornadofx.
Or do you want to create the form without Builders?
from tornadofx.
I was wondering that too. Is there a function for tabpane?
from tornadofx.
Yes, it is right at the top of tornadofx/Builders.kt
.
Update: That could be new functions that were added after release 1.2.2.
Update update: Yes, they were added right after the last release.
from tornadofx.
I must have overlooked that. I assumed the builder was missing but that does not appear to be the case. Odd. That aside I'm really liking this library. This comes a long way from my messy Swing applications from back in the day.
I'm going to use RxJavaFX with this next to get some reactive stuff going. Please let me know if we need to file a bug with JetBrain on the tabpane
issue.
class MainApp : App() {
override val primaryView = MainView::class
class MainView : View() {
override val root = StackPane()
init {
with(root) {
setPrefSize(500.0, 500.0)
hbox {
this += with(TabPane()) {
with (tabs) {
add(Tab("Tab 1"))
add(Tab("Tab 2"))
add(Tab("Tab 3"))
}
this
}
vbox {
button("Bttn 1")
button("Bttn 2")
}
}
}
}
}
}
from tornadofx.
a bug with JetBrain on the tabpane issue
It's all ok. IntelliJ didn't find it, because it doesn't exist in TornadoFX 1.2.2.
from tornadofx.
I was just about to post that because my decompiled BuildersKt.class
didn't have it.
// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available
package tornadofx
private fun <T : javafx.scene.Node> opcr(pane: javafx.scene.layout.Pane, node: T, op: (T.() -> kotlin.Unit)? /* = compiled code */): T { /* compiled code */ }
public fun javafx.scene.layout.Pane.button(text: kotlin.String /* = compiled code */, op: (javafx.scene.control.Button.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.control.Button { /* compiled code */ }
public fun javafx.scene.layout.Pane.checkbox(text: kotlin.String? /* = compiled code */, op: (javafx.scene.control.CheckBox.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.control.CheckBox { /* compiled code */ }
public fun javafx.scene.layout.Pane.datepicker(op: (javafx.scene.control.DatePicker.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.control.DatePicker { /* compiled code */ }
public fun javafx.scene.layout.Pane.gridpane(op: (javafx.scene.layout.GridPane.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.layout.GridPane { /* compiled code */ }
public fun javafx.scene.layout.Pane.hbox(spacing: kotlin.Double? /* = compiled code */, children: kotlin.collections.Iterable<javafx.scene.Node>? /* = compiled code */, op: (javafx.scene.layout.HBox.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.layout.HBox { /* compiled code */ }
public fun javafx.scene.layout.Pane.imageview(url: kotlin.String? /* = compiled code */, op: (javafx.scene.image.ImageView.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.image.ImageView { /* compiled code */ }
public fun javafx.scene.layout.Pane.label(text: kotlin.String /* = compiled code */, op: (javafx.scene.control.Label.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.control.Label { /* compiled code */ }
public fun javafx.scene.layout.Pane.progressBar(initialValue: kotlin.Double? /* = compiled code */, op: (javafx.scene.control.ProgressBar.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.control.ProgressBar { /* compiled code */ }
public fun javafx.scene.layout.Pane.progressIndicator(op: (javafx.scene.control.ProgressIndicator.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.control.ProgressIndicator { /* compiled code */ }
public fun javafx.scene.layout.HBox.spacer(prio: javafx.scene.layout.Priority /* = compiled code */, op: (javafx.scene.layout.Pane.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.layout.Pane { /* compiled code */ }
public fun javafx.scene.layout.VBox.spacer(prio: javafx.scene.layout.Priority /* = compiled code */, op: (javafx.scene.layout.Pane.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.layout.Pane { /* compiled code */ }
public fun javafx.scene.layout.Pane.stackpane(initialChildren: kotlin.collections.Iterable<javafx.scene.Node>? /* = compiled code */, op: (javafx.scene.layout.StackPane.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.layout.StackPane { /* compiled code */ }
public fun javafx.scene.layout.Pane.textarea(value: kotlin.String? /* = compiled code */, op: (javafx.scene.control.TextArea.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.control.TextArea { /* compiled code */ }
public fun javafx.scene.layout.Pane.textfield(value: kotlin.String? /* = compiled code */, op: (javafx.scene.control.TextField.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.control.TextField { /* compiled code */ }
public fun javafx.scene.layout.Pane.titledPane(title: kotlin.String, node: javafx.scene.Node): javafx.scene.control.TitledPane { /* compiled code */ }
public fun javafx.scene.layout.Pane.toolbar(vararg nodes: javafx.scene.Node, op: (javafx.scene.control.ToolBar.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.control.ToolBar { /* compiled code */ }
public fun javafx.scene.layout.Pane.vbox(spacing: kotlin.Double? /* = compiled code */, children: kotlin.collections.Iterable<javafx.scene.Node>? /* = compiled code */, op: (javafx.scene.layout.VBox.() -> kotlin.Unit)? /* = compiled code */): javafx.scene.layout.VBox { /* compiled code */ }
from tornadofx.
I just released TornadoFX 1.2.3 with the new builders (and binding support), so now you can write:
override val root = HBox()
init {
with(root) {
tabpane {
tab("Tab 1") {
// Content for tab 1 here
}
tab("Tab 2") // and so forth :)
}
}
}
If you find any missing builders or have more questions about how to do stuff, don't hesitate to ask @thomasnield. (But create new issues :)
Thanks for helping out again @hastebrot :)
from tornadofx.
Awesome thanks! I may file PR's if I find any missing builders, so you guys can focus on the more complicated stuff you're working on.
from tornadofx.
Related Issues (20)
- TornadoFx ClassCastException HOT 1
- Accessing nodes with less code HOT 4
- Advanced Data Controls Guide Clarification HOT 1
- Unbind TextField text property from non-String property HOT 2
- Font not loading HOT 1
- AsyncKt cannot access class com.sun.glass.ui.Application HOT 5
- EventBus.fire does not check for listeners of superclass types HOT 1
- Set window icons for Alerts
- Hot reload doesn't work with openjdk
- a bug with toggleClass HOT 2
- TornadoFx stackpane overlapping with menubar
- How can i build a native image using tornadofx HOT 1
- Localization of german Double values
- Data Driven TreeView HOT 1
- how to use field()? | and why field() cant' be used without form()? HOT 2
- Tornadofx with Spring security
- Is this not longer maintained? HOT 8
- Looking for maintainers HOT 1
- Guilde is not available HOT 1
- Documentation does not work HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tornadofx.