本文整理汇总了Scala中scalafx.scene.control.Button类的典型用法代码示例。如果您正苦于以下问题:Scala Button类的具体用法?Scala Button怎么用?Scala Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Button类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: PackageActionButtons
//设置package包名称以及导入依赖的类
package mco.ui.desktop.components
import scalafx.Includes._
import scalafx.geometry.{Insets, Pos}
import scalafx.scene.control.Button
import scalafx.scene.layout.{HBox, Priority, Region}
import mco.{ContentKind, Package}
import mco.ui.desktop.UIComponent
import mco.ui.state.{InstallPackage, UIAction, UninstallPackage}
import fx.tools.cats._
import cats.syntax.functor._
object PackageActionButtons extends UIComponent[Option[Package], HBox] {
override def apply(state: ObservableValueM[Option[Package]], act: (UIAction) => Unit): HBox =
new HBox {
hgrow = Priority.Always
alignmentInParent = Pos.CenterRight
padding = Insets(10, 0, 10, 0)
spacing = 10
children = Seq(
new Region {
minWidth = 10
maxWidth = Double.MaxValue
hgrow = Priority.Always
},
new Button("View README") {
prefWidth = 125
disable <== state.map(!_.exists(_.contents.exists(_.kind == ContentKind.Doc)))
onMouseClicked = handle { sys.error("Readme not implemented") }
},
new Button {
prefWidth = 125
text <== state.map {
case Some(p) if p.isInstalled => "Uninstall"
case _ => "Install"
}
disable <== state.map(_.isEmpty)
onAction <== state.map {
_.fold(handle { })( x =>
handle { act(if (!x.isInstalled) InstallPackage(x) else UninstallPackage(x)) })
}
defaultButton = true
}
)
}
}
开发者ID:oleg-py,项目名称:mco,代码行数:48,代码来源:PackageActionButtons.scala
示例2: newName
//设置package包名称以及导入依赖的类
package net.mikolak.pomisos.crud
import java.util.function.Predicate
import org.controlsfx.validation.{Severity, ValidationResult, ValidationSupport, Validator}
import scalafx.beans.property.{ObjectProperty, ReadOnlyObjectProperty}
import scalafx.event.ActionEvent
import scalafx.scene.control.{Button, TextField}
import scalafxml.core.macros.sfxml
import scalafx.Includes._
import scalafx.beans.binding.Bindings
import net.mikolak.pomisos.utils.Implicits._
trait AddNew {
def newName: ObjectProperty[Option[String]]
}
@sfxml
class AddNewController(
val addNewArea: TextField,
val addNewButton: Button
) extends AddNew {
lazy val newName = ObjectProperty[Option[String]](None)
setUpValidation()
def addItem(event: ActionEvent): Unit = {
newName.value = Some(addNewArea.text.value.toString).filter(_.nonEmpty)
addNewArea.text.value = ""
}
private def setUpValidation() = {
val textEmpty = addNewArea.text.mapToBoolean(_.trim().isEmpty)
addNewButton.disable <== textEmpty
val createItemHandle = addNewArea.onAction.value
def textValidator =
Validator.createPredicateValidator(new Predicate[String] {
override def test(t: String) = !textEmpty.value
}, "Name must not be empty", Severity.WARNING)
val validationSupport = new ValidationSupport()
validationSupport.registerValidator(addNewArea, textValidator)
validationSupport.initInitialDecoration()
val validationResult: ReadOnlyObjectProperty[ValidationResult] = validationSupport.validationResultProperty()
addNewArea.onAction <== validationResult.mapNullable(vR => if (vR.exists(_.getWarnings.isEmpty)) createItemHandle else null)
}
}
开发者ID:mikolak-net,项目名称:pomisos,代码行数:54,代码来源:AddNewController.scala
示例3: Sidebar
//设置package包名称以及导入依赖的类
package org.narrativeandplay.hypedyn.uicomponents
import scalafx.Includes._
import scalafx.geometry.Orientation
import scalafx.scene.Group
import scalafx.scene.control.{Label, Button, ToolBar}
object Sidebar extends ToolBar {
orientation = Orientation.Vertical
class SidebarButton(labelText: String) extends Button {
private val buttonLabel = new Label(labelText) {
rotate = -90
}
def buttonText = buttonLabel.text
def buttonText_=(inText: String): Unit = {
buttonLabel.text = inText
}
graphic = new Group(buttonLabel)
}
private lazy val factsButton = new SidebarButton("Hide facts") {
onAction = { _ =>
if (CentrePane.FactsPane.isShown) {
CentrePane.hide(CentrePane.FactsPane)
buttonText = "Show facts"
}
else {
CentrePane.show(CentrePane.FactsPane)
buttonText = "Hide facts"
}
}
}
items += factsButton
}
开发者ID:narrativeandplay,项目名称:hypedyn2,代码行数:41,代码来源:Sidebar.scala
注:本文中的scalafx.scene.control.Button类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论