本文整理汇总了Scala中scalafx.scene.control.Label类的典型用法代码示例。如果您正苦于以下问题:Scala Label类的具体用法?Scala Label怎么用?Scala Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Label类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: FileInfo
//设置package包名称以及导入依赖的类
package strnet
import java.io.File
import scala.sys.process._
import scalafx.Includes._
import org.apache.commons.io.FilenameUtils
import scalafx.scene.control.Label
import scalafx.scene.image.{ Image, ImageView }
import scalafx.scene.input.MouseEvent
import scalafx.scene.layout.VBox
class FileInfo(
file: File,
command: String,
thumbnailExtension: String,
defaultImg: Image)
extends VBox {
val baseName = FilenameUtils.getBaseName(file.getName)
val imgFile = new File(FilenameUtils.removeExtension(file.getPath()) + thumbnailExtension)
val img = if ( imgFile.exists() ) {
new Image(imgFile.toURI().toString)
} else {
defaultImg
}
val imageView = new ImageView(img) {
preserveRatio = true
smooth = false
}
if (img.getWidth > 120) {
imageView.fitWidth = 120
}
if (img.getHeight > 120) {
imageView.fitHeight = 120
}
onMouseClicked = (e: MouseEvent) => new Thread() {
override def run() {
Seq(command, file.getPath).!
}
}.start()
styleClass.append("thumbnail")
children.addAll(
imageView,
new Label(baseName))
alignment = scalafx.geometry.Pos.TopCenter
}
示例2: 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
}