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

Scala Scene类代码示例

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

本文整理汇总了Scala中scalafx.scene.Scene的典型用法代码示例。如果您正苦于以下问题:Scala Scene类的具体用法?Scala Scene怎么用?Scala Scene使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Scene类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
            }
          }
        )
      }
    }

  }
} 
开发者ID:dariyavis,项目名称:scalaFXStart,代码行数:49,代码来源:ScalaFXHelloWorld.scala


示例2: Main

//设置package包名称以及导入依赖的类
import java.io.IOException
import javafx.{fxml => jfxf}
import javafx.{scene => jfxs}
import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene

object Main extends JFXApp {

  val resource = getClass.getResource("hello.fxml")
  if (resource == null) {
    throw new IOException("Cannot load resource: hello.fxml")
  }

  val root: jfxs.Parent = jfxf.FXMLLoader.load(resource)

  stage = new PrimaryStage() {
    title = "ScalaFX Sandbox"
    scene = new Scene(root)
  }
} 
开发者ID:Germanika,项目名称:ScalaFX-Sandbox,代码行数:23,代码来源:Main.scala


示例3: Gui

//设置package包名称以及导入依赖的类
package strnet

import java.io.{ File, FileInputStream }
import java.util.Properties

import scalafx.Includes._
import scalafx.application.JFXApp.PrimaryStage
import scalafx.application.{ JFXApp, Platform }
import scalafx.scene.Scene
import scalafx.scene.image.Image
import scalafx.scene.control._
import scalafx.scene.layout._
import scalafx.stage.WindowEvent

object Gui extends JFXApp {
  val commonProp = new Properties
  commonProp.load(new FileInputStream(new File("conf" + File.separator + "common.conf")))

  val dir = new File(commonProp.getProperty("directories.path"))
  val command = commonProp.getProperty("exec.path")

  val defaultImg = new Image(new File("conf" + File.separator + "no.jpg").toURI().toString)

  val rootPane = new BorderPane()
  val listPane = new FlowPane(10, 10)
  val scrollPane = new ScrollPane()
  scrollPane.setContent(listPane)
  listPane.prefWidth.bind(scrollPane.width)
  listPane.prefHeight.bind(scrollPane.height)
  scrollPane.styleClass.append("base")


  rootPane.setCenter(scrollPane)

  def scanFiles(dir: File): Unit = {
    val thumbnails = dir.listFiles.filter(f => f.isFile && !f.getName.matches(".*\\.jpg"))
    thumbnails.foreach { f => listPane.children.add(new FileInfo(f, command, ".jpg", defaultImg)) }
  }

  stage = new PrimaryStage {
    title = "Bestiary"
    scene = new Scene(rootPane, 1280, 768) {
      stylesheets.add("/strnet/main.css")
    }
    onCloseRequest = (we: WindowEvent) => Platform.exit()
  }

  println(dir + ":" + dir.exists())
  if ( dir.exists() && dir.isDirectory() ) {
    scanFiles(dir)
  }
} 
开发者ID:hossshy,项目名称:bestiary,代码行数:53,代码来源:Gui.scala


示例4: HelloStageDemo

//设置package包名称以及导入依赖的类
import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.scene.Scene
import scalafx.scene.paint.Color._
import scalafx.scene.shape.Rectangle

object HelloStageDemo extends JFXApp {
  stage = new JFXApp.PrimaryStage {
    title.value = "Hello Stage"
    width = 600
    height = 450
    scene = new Scene {
      fill = LightGreen
      content = new Rectangle {
        x = 25
        y = 40
        width = 100
        height = 100
        fill <== when (hover) choose Green otherwise Red
      }
    }
  }
} 
开发者ID:nenad-spuzic,项目名称:scalaFX-executable-jar,代码行数:24,代码来源:HelloStageDemo.scala


示例5: Empty

//设置package包名称以及导入依赖的类
package org.rustkeylock.fragments

import scalafx.scene.Scene
import scalafx.scene.layout.BorderPane
import scalafx.scene.layout.VBox
import scalafx.scene.image.ImageView
import scalafx.scene.paint.LinearGradient
import scalafx.scene.effect.DropShadow
import scalafx.scene.text.Text
import scalafx.geometry.Pos

class Empty() extends Scene {
  root = new VBox() {
    style = "-fx-background: white"
    alignment = Pos.Center
    children = Seq(
      new ImageView("images/rkl.png"),
      new Text {
        text = "rust-keylock"
        style = "-fx-font-size: 48pt"
      })
  }
} 
开发者ID:rust-keylock,项目名称:rust-keylock-ui,代码行数:24,代码来源:Empty.scala


示例6: MainMenu

//设置package包名称以及导入依赖的类
package org.rustkeylock.fragments

import scalafx.Includes._
import scalafx.scene.Scene
import org.slf4j.LoggerFactory
import com.typesafe.scalalogging.Logger
import scalafx.scene.layout.GridPane
import scalafx.geometry.Insets
import scalafx.scene.layout.BorderPane
import org.rustkeylock.fragments.sides.Navigation
import scalafx.scene.control.ScrollPane
import scalafx.scene.layout.VBox
import scalafx.scene.control.ScrollPane.ScrollBarPolicy
import scalafx.scene.control.ListView
import scalafx.scene.text.Text
import scalafx.scene.paint.Stops
import scalafx.geometry.Pos
import scalafx.scene.image.ImageView
import scalafx.stage.Stage

class MainMenu(stage: Stage) extends Scene {
  val logger = Logger(LoggerFactory.getLogger(this.getClass))

  root = new BorderPane() {
    style = "-fx-background: white"
    // Navigation pane
    left = new Navigation
    // Main pane
    center = new ScrollPane {
      fitToHeight = true
      hbarPolicy = ScrollBarPolicy.AsNeeded
      vbarPolicy = ScrollBarPolicy.AsNeeded
      content = new Center
    }
  }

  private class Center extends VBox {
    spacing = 33
    padding = Insets(10, 10, 10, 10)
    alignment = Pos.Center

    children = Seq(
      new ImageView("images/rkl.png"),
      new Text {
        style = "-fx-font-size: 12pt"
        text = "Please make a selection"
      },
      new Text {
        style = "-fx-font-size: 12pt"
        text = "on the Navigation bar on the left in order to proceed"
      })
  }

} 
开发者ID:rust-keylock,项目名称:rust-keylock-ui,代码行数:55,代码来源:MainMenu.scala


示例7: UnitConverterPresenter

//设置package包名称以及导入依赖的类
package com.stulsoft.pscalafx.demo1

import scala.reflect.runtime.universe.typeOf
import scalafx.application.{Platform, JFXApp}
import scalafx.Includes._
import scalafx.scene.Scene
import scalafx.scene.control.{ComboBox, TextField}
import scalafx.event.ActionEvent
import scalafxml.core.{DependenciesByType, FXMLView}
import scalafxml.core.macros.sfxml
import javafx.beans.binding.StringBinding


@sfxml
class UnitConverterPresenter(from: TextField,
                             to: TextField,
                             types: ComboBox[UnitConverter],
                             converters: UnitConverters) {

  // Filling the combo box
  for (converter <- converters.available) {
    types += converter
  }
  types.getSelectionModel.selectFirst()

  // Data binding
  to.text <== new StringBinding {
    bind(from.text.delegate, types.getSelectionModel.selectedItemProperty)

    def computeValue(): String = types.getSelectionModel.getSelectedItem.run(from.text.value)
  }

  // Close button event handler
  def onClose(event: ActionEvent) {
    Platform.exit()
  }
}

object ScalaFXML extends JFXApp {

  val root = FXMLView(getClass.getResource("/fxml/unitconverter.fxml"),
    new DependenciesByType(Map(
      typeOf[UnitConverters] -> new UnitConverters(InchesToMM, MMtoInches))))

  stage = new JFXApp.PrimaryStage() {
    title = "Unit conversion"
    scene = new Scene(root)

  }
} 
开发者ID:ysden123,项目名称:poc,代码行数:51,代码来源:ScalaFXML.scala


示例8: ScalaFXHelloWorld

//设置package包名称以及导入依赖的类
package my.scalafx

import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene
import scalafx.scene.layout.BorderPane
import scalafx.scene.paint.Color
import scalafx.scene.web.WebView

object ScalaFXHelloWorld extends JFXApp {

  val webView = new  WebView()
  webView.getEngine.loadContent(
    """
      <audio controls #player src="http://www.largesound.com/ashborytour/sound/AshboryBYU.mp3" preload="none">
        Your browser does not support the audio element.
      </audio>
      """
  )

  stage = new PrimaryStage {
    title = "ScalaFX Hello World"
    scene = new Scene {
      fill = Color.rgb(38, 38, 38)
      content = new BorderPane {
        center = webView
      }
    }

  }
} 
开发者ID:setrar,项目名称:scalaFX-html5-audio,代码行数:32,代码来源:ScalaFXHelloWorld.scala


示例9: Main

//设置package包名称以及导入依赖的类
package com.ruimo.forms

import javafx.{fxml => jfxf}
import javafx.{scene => jfxs}
import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene

object Main extends JFXApp {
  val resource = getClass.getResource("main.fxml")
  if (resource == null) {
    throw new RuntimeException("Cannot load resource: main.fxml")
  }

  {
    val loader = new jfxf.FXMLLoader(resource)
    val root: jfxs.Parent = loader.load()

    stage = new PrimaryStage() {
      title = "Form Builder"
      scene = new Scene(root)
    }

    val controller: MainController = loader.getController().asInstanceOf[MainController]
    controller.setStage(stage);
  }
} 
开发者ID:ruimo,项目名称:formBuilder,代码行数:29,代码来源:Main.scala


示例10: JasyptUi

//设置package包名称以及导入依赖的类
package org.utkuozdemir.jasyptui

import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene
import scalafx.scene.image.Image
import scalafxml.core.{FXMLView, NoDependencyResolver}


object JasyptUi extends JFXApp {
  val resource = getClass.getResource("JasyptUi.fxml")

  val root = FXMLView(resource, NoDependencyResolver)

  stage = new PrimaryStage() {
    title = "Jasypt Encrypt/Decrypt Tool"
    scene = new Scene(root)
  }

  stage.setMinHeight(500)
  stage.setMinWidth(720)

  stage.icons.add(new Image("saru.png"))
} 
开发者ID:utkuozdemir,项目名称:jasypt-ui,代码行数:26,代码来源:JasyptUi.scala


示例11: Main

//设置package包名称以及导入依赖的类
package de.pi.photo.frame.view

import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.scene.Scene
import scalafx.scene.paint.Color._
import scalafxml.core.DependenciesByType
import scalafxml.core.FXMLView
import scalafx.application.Platform



object Main extends JFXApp {
	
	stage = new JFXApp.PrimaryStage {
    title.value = "Pi Photo Frame"
    
    scene = new Scene(
        FXMLView(
            getClass.getResource("/main.fxml"),
            new DependenciesByType(Map()))
    )
    
    maximized = true    
		fullScreen = true   
  }
	
} 
开发者ID:saig0,项目名称:pi-photo-frame,代码行数:29,代码来源:Main.scala


示例12: App

//设置package包名称以及导入依赖的类
package de.m7w3.signal

import java.security.Security

import de.m7w3.signal.controller.{DeviceRegistration, UnlockDB}
import org.whispersystems.libsignal.logging.SignalProtocolLoggerProvider

import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene

object App {
  val NAME = "signal-desktop"
  val VERSION = "0.0.1"
  val AUTHOR = "motherflippers"
}

object Main extends JFXApp {
  Security.insertProviderAt(new org.bouncycastle.jce.provider.BouncyCastleProvider(), 1)
  SignalProtocolLoggerProvider.setProvider(new ProtocolLogger())


  val signalDesktopConfig = Config.optionParser.parse(parameters.raw, Config.SignalDesktopConfig())
  signalDesktopConfig.foreach { config =>
    val ctxBuilder = ContextBuilder(config)
    val root = if (ctxBuilder.profileDirExists && ctxBuilder.profileIsInitialized) {
      UnlockDB(ctxBuilder)
    } else {
      // show welcome and registration screen
      DeviceRegistration.load(ctxBuilder)
    }
    stage = new PrimaryStage {
      title = "Welcome"
      scene = new Scene(root)
    }
  }

  override def stopApp(): Unit = {
    // cleanup shit
    ApplicationContext.getCurrent.foreach(_.close())
    println("bye!")
    super.stopApp()
  }
} 
开发者ID:ayoub-benali,项目名称:signal-desktop-client,代码行数:45,代码来源:Main.scala


示例13: Bozzy

//设置package包名称以及导入依赖的类
package bozzy

import java.io.FileNotFoundException

import bozzy.controllers.MainDictionary

import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene
import scalafx.scene.input.{TransferMode, DragEvent}
import scalafx.scene.text.Font
import scalafxml.core.{NoDependencyResolver, FXMLLoader}


object Bozzy extends JFXApp {
  Font.loadFont(
    getClass.getResource("/fonts/symbola_hint_8.ttf").toExternalForm,
    14
  )
  val main = getClass.getResource("/view/Main.fxml")
  if (main == null) {
    throw new FileNotFoundException("Cannot load resource: /view/Main.fxml")
  }
  val loader = new FXMLLoader(main, NoDependencyResolver) {
    setResources(I18n.i18n)
  }
  val root = loader.load[javafx.scene.Parent]

  stage = new PrimaryStage() {
    title = I18n.i18n.getString("applicationTitle")
    scene = new Scene(root) {
      stylesheets = List(getClass.getResource("/css/style.css").toExternalForm)
      onDragOver = (event: DragEvent) => {
        if (event.dragboard.hasFiles) {
          event acceptTransferModes TransferMode.COPY
        }
        event.consume
      }
      onDragDropped = (event: DragEvent) => {
        if (event.dragboard.hasFiles) {
          event.dragboard.files foreach (file => {
            file.getAbsolutePath.split('.').last.toLowerCase match {
              case "rtf" | "json" => {
                MainDictionary.addDictionary(file.getAbsolutePath)
                event.dropCompleted = true
              }
              case _ => event.dropCompleted = false
            }
          })
        }
        event.consume
      }
    }
  }
} 
开发者ID:morinted,项目名称:Bozzy,代码行数:57,代码来源:Bozzy.scala


示例14: 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
            }
          }
        )
      }
    }
  }
} 
开发者ID:bpupadhyaya,项目名称:scala-programs-collection,代码行数:48,代码来源:SampleScalaFXApp2.scala


示例15: Main

//设置package包名称以及导入依赖的类
package hatanas.browser

import javafx.scene.Parent

import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene
import scalafxml.core.{FXMLLoader, FXMLView, NoDependencyResolver}


object Main extends JFXApp {

    val resource = getClass.getResource("SimpleBrowser.fxml")
    val loader = new FXMLLoader(resource, NoDependencyResolver)
    loader.load()
    val root = loader.getRoot[Parent]
    val controller = loader.getController[BrowserControllerInitializable]
    controller.initialize(parameters.raw.applyOrElse(0, (n: Int) => "404.html"))

    stage = new PrimaryStage() {
        title = "Simple Browser"
        scene = new Scene(root)
    }
} 
开发者ID:Hatanas,项目名称:SimpleBrowser,代码行数:26,代码来源:Main.scala


示例16: Main

//设置package包名称以及导入依赖的类
package graph

import java.io.IOException
import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.Scene
import scalafxml.core.{NoDependencyResolver, FXMLView}

object Main extends JFXApp {
  val fxmlFile = "View.fxml"

  val resource = getClass.getClassLoader.getResource(fxmlFile)
  if (resource == null) {
    throw new IOException("Cannot load resource: " + fxmlFile)
  }

  val root = FXMLView(resource, NoDependencyResolver)

  stage = new PrimaryStage() {
    title = "Graph Visualizer"
    scene = new Scene(root)
  }

} 
开发者ID:lmdexpr,项目名称:graph-visualizer,代码行数:26,代码来源:Main.scala



注:本文中的scalafx.scene.Scene类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala MapType类代码示例发布时间:2022-05-23
下一篇:
Scala avg类代码示例发布时间: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