Skip to content

CheckBox

Brian edited this page Jul 3, 2018 · 4 revisions
import javafx.geometry.Pos
import javafx.scene.paint.Color
import tornadofx.*

class JFXCheckBoxTestApp : App(Main::class, MyStyles::class) {

    class Main: View() {
        val isValid = SimpleBooleanProperty(true)
        val user = UserModel(User("John Doe", "johnd", "oe", "[email protected]"))

        override val root = vbox {
            addClass(MyStyles.box)
            form {
                fieldset("User Information") {
                    field("Name") {
                        jfxtextfield(user.name)
                    }
                    field("Login") {
                        jfxtextfield(user.login)
                    }
                    field("Password") {
                        jfxtextfield(user.password)
                    }
                    field("Email") {
                        jfxtextfield(user.email)
                    }
                    field("Valid") {
                        jfxcheckbox(isValid) // use of JFXCheckBox
                    }
                }
            }
        }
    }

    class MyStyles: JFXStylesheet() {

        companion object {
            val bar by cssclass()
            val box by cssclass()
            val customerBtn by cssclass()
            val defaultColor = Color.web("#4059a9")
        }

        init {
            jfxButton {
                backgroundColor += defaultColor
                textFill = Color.WHITE
            }

            bar {
                alignment = Pos.CENTER_RIGHT
                spacing = 10.px
            }

            box {
                prefHeight = 600.px
                prefWidth = 800.px
            }

            customerBtn {
                backgroundColor += Color.TRANSPARENT
                jfxRippler {
                     jfxRipplerFill.value = Color.GRAY
                }
            }
        }
}
Clone this wiki locally