• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala Button类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala nonEmptyText类代码示例发布时间:2022-05-23
下一篇:
Scala StreamSource类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap