本文整理汇总了Scala中scalafx.scene.layout.HBox类的典型用法代码示例。如果您正苦于以下问题:Scala HBox类的具体用法?Scala HBox怎么用?Scala HBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HBox类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ScalaFXHelloWorld
//设置package包名称以及导入依赖的类
package hello
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.geometry.Insets
import scalafx.scene.Scene
import scalafx.scene.effect.DropShadow
import scalafx.scene.layout.HBox
import scalafx.scene.paint.Color._
import scalafx.scene.paint._
import scalafx.scene.text.Text
object ScalaFXHelloWorld extends JFXApp {
stage = new PrimaryStage {
// initStyle(StageStyle.Unified)
title = "ScalaFX Hello World"
scene = new Scene {
fill = Color.rgb(38, 38, 38)
content = new HBox {
padding = Insets(50, 80, 50, 80)
children = Seq(
new Text {
text = "Scala"
style = "-fx-font: normal bold 100pt sans-serif"
fill = new LinearGradient(
endX = 0,
stops = Stops(Red, DarkRed))
},
new Text {
text = "FX"
style = "-fx-font: italic bold 100pt sans-serif"
fill = new LinearGradient(
endX = 0,
stops = Stops(White, DarkGray)
)
effect = new DropShadow {
color = DarkGray
radius = 15
spread = 0.25
}
}
)
}
}
}
}
示例2: RepoTab
//设置package包名称以及导入依赖的类
package mco.ui.desktop.components
import scalafx.geometry.Insets
import scalafx.scene.control.Tab
import scalafx.scene.layout.{HBox, VBox}
import alleycats.Empty
import cats.implicits._
import cats.derived.empty._, legacy._
import mco.ui.desktop.UIComponent
import mco.ui.state.{UIAction, UIState}
import fx.tools.cats._
import mco.ui.state.UIState.PendingAdds
object RepoTab extends UIComponent[UIState, Tab] {
override def apply(state: ObservableValueM[UIState], act: (UIAction) => Unit): Tab = new Tab {
text <== state.map(_.repoName)
closable = false
content = new HBox { contentRoot =>
padding = Insets(10)
private val mainView = Seq(
RepoPackagesTable(state, act),
new VBox {
padding = Insets(0, 0, 0, 10)
prefWidth <== (contentRoot.width / 3)
children = Seq(
PackageThumbnail(state.map(_.thumbnailURL) product width, act),
PackageContentTable(state.map(_.currentPackage.map(_.contents).getOrElse(Set())), act),
PackageActionButtons(state.map(_.currentPackage), act)
)
}
)
private val adds = state.map(_.pendingAdds.getOrElse(Empty[PendingAdds].empty))
private lazy val pendingAddsView = Seq(BulkAssoc(adds, act))
children <== state.map { s =>
if (s.pendingAdds.isEmpty) mainView
else pendingAddsView
}
}
}
}
示例3: 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
}
)
}
}
示例4:
//设置package包名称以及导入依赖的类
package com.github.oopman.collectioneer.ui
import com.github.oopman.collectioneer.model.Collection
import scalafx.geometry.Insets
import scalafx.scene.control.{ListCell, ListView}
import scalafx.scene.layout.HBox
import scalafx.scene.text.Text
cellFactory = { _ =>
new ListCell[Collection] {
item.onChange { (_, _, newValue) =>
graphic = new HBox {
padding = Insets(5, 10, 5, 10)
children = Seq(
// TODO: Use proper controls
new Text { text = newValue.name },
new Text { text = if(newValue.active) "X" else "O" }
)
}
}
}
}
}
示例5: ExperimenterImageTab
//设置package包名称以及导入依赖的类
package com.antiparagon.cvexperimenter.gui
import scalafx.geometry.{Insets, Pos}
import scalafx.scene.control.{ScrollPane, Tab}
import scalafx.scene.image.{Image, ImageView}
import scalafx.scene.layout.{HBox, VBox}
class ExperimenterImageTab(val img : Image) extends Tab with ExperimenterTab {
content = new VBox {
padding = Insets(20)
style = "-fx-background-color: black"
alignment = Pos.Center
children = Seq(
new HBox {
alignment = Pos.Center
children = new ScrollPane {
style = "-fx-background-color: black"
//alignment = Pos.Center
val imgView = new ImageView(img)
imgView.style = "-fx-background-color: transparent"
content = imgView
}
}
)
}
override def getImg() : Image = return img
override def getTabText(): String = text.value
}
示例6: SampleScalaFXApp2
//设置package包名称以及导入依赖的类
package com.equalinformation.scala.programs.gui
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.geometry.Insets
import scalafx.scene.Scene
import scalafx.scene.effect.DropShadow
import scalafx.scene.layout.HBox
import scalafx.scene.paint.Color._
import scalafx.scene.paint.{LinearGradient, Stops}
import scalafx.scene.text.Text
object SampleScalaFXApp2 extends JFXApp {
//TODO Resolve run-time issue
stage = new PrimaryStage {
title = "ScalaFX Sample App2"
scene = new Scene {
fill = Black
content = new HBox {
padding = Insets(20)
children = Seq(
new Text {
text = "Sample "
style = "-fx-font-size: 48pt"
fill = new LinearGradient(
endX = 0,
stops = Stops(PaleGreen, SeaGreen))
},
new Text {
text = "App2!!!"
style = "-fx-font-size: 48pt"
fill = new LinearGradient(
endX = 0,
stops = Stops(Cyan, DodgerBlue)
)
effect = new DropShadow {
color = DodgerBlue
radius = 25
spread = 0.25
}
}
)
}
}
}
}