您的位置 首页 > 腾讯云社区

javafx框架tornadofx入门29_类型安全的样式-内联样式---用户6167008

tornadofx中可以在控件的lambda表达式中通过style {}的方式给控件定义样式

class MainView29 : View("tornadofx入门29_类型安全的样式-内联样式") { override val root = hbox(30) { alignment = Pos.CENTER button("tornadofx button") { style="fx-font-size:10px;"// 以字符串的形式定义样式,会被下面定义的样式覆盖 // 为按钮定义样式,默认会覆盖在其他位置给该按键定义的样式, // 如果想追加新的样式,则需采取style(append = true)的形式 style { // 定义字体粗细 fontWeight = FontWeight.EXTRA_BOLD // 定义边框颜色 borderColor += box(top = Color.RED, right = Color.DARKGREEN,left = Color.ORANGE, bottom = Color.PURPLE) // 定义字体 fontFamily = "Comic Sans MS" // 定义字体大小 fontSize = 20.px // 定义旋转角度 rotate = 30.deg } } button("tornadofx button1") { style="fx-font-size:10px;" //在原有样式上追加新的样式 style(append = true) { //背景色 backgroundColor += Color.AZURE //显示字体颜色 textFill = c("green") fontWeight = FontWeight.THIN borderColor += box(c("#FF0000"), c("darkgreen"), c("purple"), c("orange")) rotate = (-30).deg } } button("tornadofx button2") { style { rotate = 90.deg } } setPrefSize(400.0,400.0) } } ---来自腾讯云社区的---用户6167008

关于作者: 瞎采新闻

这里可以显示个人介绍!这里可以显示个人介绍!

热门文章

留言与评论(共有 0 条评论)
   
验证码: