All Projects → hendraanggrian → ktfx

hendraanggrian / ktfx

Licence: Apache-2.0 License
Kotlin extensions for JavaFX app development

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to ktfx

Jacob
A lightweight library to provide coroutines in Java
Stars: ✭ 14 (+7.69%)
Mutual labels:  coroutines
msgbots
Messenger Bot Simulator ( Rhino )
Stars: ✭ 17 (+30.77%)
Mutual labels:  javafx
FXFileChooser
Custom JavaFX file chooser which allows quick manual filtering, which allows to add Path predicates as filter and which is testable using TestFX.
Stars: ✭ 22 (+69.23%)
Mutual labels:  javafx
AsyncUtils
A set of utilities for Asynchronous programming in Unity.
Stars: ✭ 15 (+15.38%)
Mutual labels:  coroutines
WebcamFX
Open the camera, take pictures 📷 & save them using Javafx.
Stars: ✭ 39 (+200%)
Mutual labels:  javafx
WanAndroidMVVM
WanAndroid 客户端,采用 Kotlin 语言编写,项目使用 JetPack-MVVM 架构,采用 Retrofit + Coroutines + Coil 等开源框架开发。
Stars: ✭ 21 (+61.54%)
Mutual labels:  coroutines
fluid-mongo
Kotlin coroutine support for MongoDB built on top of the official Reactive Streams Java Driver
Stars: ✭ 27 (+107.69%)
Mutual labels:  coroutines
AsyPad
A simple drawing tool that can convert diagrams into Asymptote code.
Stars: ✭ 18 (+38.46%)
Mutual labels:  javafx
Code2HTML
JavaFX tool for converting source code to styled HTML
Stars: ✭ 26 (+100%)
Mutual labels:  javafx
hacklympics
🏆 Full-stack online programming examination system
Stars: ✭ 44 (+238.46%)
Mutual labels:  javafx
jmonet
An easy-to-use toolkit for incorporating MacPaint / Microsoft Paint-like tools into a Java Swing or JavaFX application.
Stars: ✭ 27 (+107.69%)
Mutual labels:  javafx
insta-bot
Instagram automation library to perform likes, comments, follow, story viewing and much more.
Stars: ✭ 20 (+53.85%)
Mutual labels:  coroutines
iliasDownloaderTool
synchronize, manage and download the files from your e-learning platform https://www.ilias.de/
Stars: ✭ 46 (+253.85%)
Mutual labels:  javafx
DeezerClone
This Application using Dagger Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData),Navigation based on MVVM architecture.
Stars: ✭ 81 (+523.08%)
Mutual labels:  coroutines
Coffeegram
Android app using Jetpack Compose together with StateFlow and MVI
Stars: ✭ 155 (+1092.31%)
Mutual labels:  coroutines
Kotlin-Coroutine-Flow
Search engine functionality using Kotlin Coroutines and Flow
Stars: ✭ 25 (+92.31%)
Mutual labels:  coroutines
TinyClip
🚀 JavaFX开发的FFMPEG-GUI客户端
Stars: ✭ 59 (+353.85%)
Mutual labels:  javafx
ktPlayer-Music-Player
ktPlayer - Music Player on Java 8 with using JavaFX (Desktop)
Stars: ✭ 22 (+69.23%)
Mutual labels:  javafx
coroutine monad
Using coroutines as sugar for composing monadic operations
Stars: ✭ 59 (+353.85%)
Mutual labels:  coroutines
SporeModder-FX
The most advanced and modern Spore modding tool.
Stars: ✭ 24 (+84.62%)
Mutual labels:  javafx

version build analysis

KtFX

Written in spirit of anko, it aims to make JavaFX app development less painful with the help of Kotlin technologies.

  • Full of helpers for common JavaFX operations.
  • Write dynamic layout with Kotlin DSL.
  • Use coroutines directly from JavaFX API.

Download

repositories {
    mavenCentral()
}

dependencies {
    // all the main artifacts combined
    compile "com.hendraanggrian.ktfx:ktfx:$version"

    // or download separately
    compile "com.hendraanggrian.ktfx:ktfx-commons:$version"
    compile "com.hendraanggrian.ktfx:ktfx-layouts:$version"
    compile "com.hendraanggrian.ktfx:ktfx-listeners:$version"
    compile "com.hendraanggrian.ktfx:ktfx-coroutines:$version"

    // third-party artifacts
    compile "com.hendraanggrian.ktfx:ktfx-controlsfx:$version"
    compile "com.hendraanggrian.ktfx:ktfx-jfoenix:$version"
}

Snapshots of the development version are available in Sonatype's snapshots repository.

Ktfx Commons

Full of extensions for JavaFX, packaged accordingly. The main goal of core library is not to add any new feature to the existing JavaFX APIs. Below are preview of some of the packages.

Collections

// create unmodifiable observable collection
val emptyUnmodifiableList = emptyObservableList()
val unmodifiableList = observableListOf(1)

// create modifiable observable collection
val emptyModifiableList = mutableObservableListOf()
val modifiableList = mutableObservableListOf(1, 2, 3)

// convert existing
val list = myList.toObservableList() // or toMutableObservableList() for modifiable version

Bindings

// infix conditional binding
button.disableProperty().bind(firstName.textProperty().isEmpty or lastName.textProperty().isEmpty)

// operator binding for number properties
totalProperty.bind(qtyProperty * priceProperty)

// infix binding for number properties
loginButton.disableProperty().bind(passwordField.textProperty.length() less 4)

// custom binding
label.graphicProperty().bind(stringBindingOf(listView.selectionModel.selectedIndexProperty()) {
    "${listView.selectionModel.selectedIndex} selected"
})
imageView.imageProperty().bind(bindingOf(urlField.textProperty()) {
    Image(urlField.text)
})

Dialogs

// show an alert
alert("Here's an alert").show()

// show a confirmation alert and wait for input
confirmAlert("Are you sure?").showAndWait()

// custom init a text input dialog
inputDialog("Question #1") {
    contentText = "Why does the chicken cross the road?"
    editor.promptText = "Hint"
}.showAndWait()

// a choice dialog
choiceDialog("Pick an item", ImageView("/my/image.png"), items)
    .showAndWait()

// show a custom dialog
dialog<String>("Who's a little piggy?") {
    content = ...
    yesButton()
    noButton()
    customButton("What's a piggy?") {
        // explain what a piggy is
    }
    resultConverter {
        if(it == button1)  "Me" else null
    }
}.showAndWait()

Ktfx Layouts

Generate JavaFX layouts, controls, shapes, and charts with Kotlin DSL. It's a direct replacement of FXML files.

gridPane {
    gaps = 8
    label("First name") row 0 col 0
    val firstName = textField() row 0 col 1
    label("Last name") row 1 col 0
    val lastName = textField() row 1 col 1
    button("Say hello") {
        onAction {
            infoAlert("Hello, ${firstName.text} ${lastName.text}!")
        }
    } row 2 col 1 hpos HPos.RIGHT
}

Ktfx Listeners

Trade common JavaFX listener with Kotlin DSL. Currently includes string converters and table cells.

// string converter
val dateBox = ChoiceBox<Date>()
dateBox.converter {
    val dateFormat = SimpleDateFormat("dd/MM/yyyy")
    fromString {
        dateFormat.parse(it)
    }
    toString {
        dateFormat.format(it)
    }
}

// custom list cell
val personList = ListView<Person>()
personList.cellFactory {
    onUpdateItem { person, empty ->
        if (person != null && !empty) {
            graphic = Button("Do something")
        }
    }
}

Ktfx Coroutines

Based on the kotlinx.coroutines library, it allows invoking JavaFX EventHandler the coroutine way.

button.setOnAction {
    doSomethingInBackground()// might freeze UI
    celebrateCompletion()
}

button.onAction(CommonPool) {
    doSomethingInBackground() // non-blocking in common pool
    launch(FX) {
        celebrateCompletion()
    }
}

Third-party

At the moment, ControlsFX and JFoenix are supported.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].