javafx控件的显示效果演示

2019-10-12 18:09:38 浏览数 (2)

代码语言:javascript复制
import javafx.scene.effect.BlurType
import javafx.scene.effect.DropShadow
import javafx.scene.image.Image
import javafx.scene.paint.Color
import javafx.scene.paint.CycleMethod
import javafx.scene.paint.LinearGradient
import javafx.scene.paint.Stop
import javafx.scene.text.Font
import tornadofx.*

class MyApp : App(EffectView::class, Mystyle::class)

class EffectView : View("控件的显示效果") {

    override val root = borderpane {
        addStageIcon(Image("tornado-fx-logo.png"))
        top = vbox(4) {
            paddingBottom = 10.0
            hbox(10) {
                label("History:") {
                    font = Font("sanserif", 80.0)
                    val stops = listOf(Stop(0.0, Color.PALEGREEN), Stop(1.0, Color.SEAGREEN))
                    val lg = LinearGradient(0.0, 0.0, 1.0, 0.0, true, CycleMethod.NO_CYCLE, stops)
                    textFill = lg
                }

                label("History:") {
                    font = Font("sanserif", 80.0)
                    val stops = listOf(Stop(0.0, Color.CYAN), Stop(1.0, Color.DODGERBLUE))
                    val lg = LinearGradient(0.0, 0.0, 1.0, 0.0, true, CycleMethod.NO_CYCLE, stops)
                    textFill = lg
                    effect = DropShadow(BlurType.GAUSSIAN, Color.DODGERBLUE, 25.0, 0.25, 0.0, 0.0)
                }
                label("History:") {
                    font = Font("sanserif", 80.0)
                    val stops = listOf(Stop(0.0, Color.CYAN), Stop(1.0, Color.DODGERBLUE))
                    val lg = LinearGradient(0.0, 0.0, 1.0, 0.0, true, CycleMethod.NO_CYCLE, stops)
                    textFill = lg
                    effect = DropShadow(BlurType.GAUSSIAN, Color.DODGERBLUE, 25.0, 0.35, 10.0, 10.0)
                }
            }

            hbox(10) {
                label("History:") {
                    font = Font("sanserif", 80.0)
                    val stops = listOf(Stop(0.0, Color.CYAN), Stop(1.0, Color.DODGERBLUE))
                    val lg = LinearGradient(0.0, 0.0, 1.0, 0.0, true, CycleMethod.NO_CYCLE, stops)
                    textFill = lg
                    effect = DropShadow(BlurType.ONE_PASS_BOX, Color.DODGERBLUE, 25.0, 0.15, 0.0, 0.0)
                }
                label("History:") {
                    font = Font("sanserif", 80.0)
                    val stops = listOf(Stop(0.0, Color.CYAN), Stop(1.0, Color.DODGERBLUE))
                    val lg = LinearGradient(0.0, 0.0, 1.0, 0.0, true, CycleMethod.NO_CYCLE, stops)
                    textFill = lg
                    effect = DropShadow(BlurType.TWO_PASS_BOX, Color.DODGERBLUE, 25.0, 0.25, 5.0, 5.0)
                }
                label("History:") {
                    font = Font("sanserif", 80.0)
                    val stops = listOf(Stop(0.0, Color.CYAN), Stop(1.0, Color.DODGERBLUE))
                    val lg = LinearGradient(0.0, 0.0, 1.0, 0.0, true, CycleMethod.NO_CYCLE, stops)
                    textFill = lg
                    effect = DropShadow(BlurType.THREE_PASS_BOX, Color.DODGERBLUE, 25.0, 0.35, 10.0, 10.0)
                }
            }
        }
    }
}

class Mystyle : Stylesheet() {
    init {
        root {
            padding = box(10.px)
            borderWidth  = box(2.px)
            borderInsets  = box(5.px)
            borderRadius  = box(5.px)
//            borderColor  = box(Color.BLUE)
//            borderStyle  = SOLID
        }
    }
}

0 人点赞