当前位置: 首页>>代码示例>>Scala>>正文


Scala JFXApp类代码示例

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


在下文中一共展示了JFXApp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: JFXAppAdapter

//设置package包名称以及导入依赖的类
package io.scalatestfx.framework.scalatest

import javafx.{stage => jfxst}
import org.testfx.api.FxToolkit
import scalafx.application.JFXApp

class JFXAppAdapter(
    val jfxAppFixture: JFXAppFixture
    ) extends javafx.application.Application {

  override def init() {
    jfxAppFixture.init()
  }

  override def start(stage: jfxst.Stage) {
    JFXApp.Stage = stage
    jfxAppFixture.start(new JFXApp.PrimaryStage)
  }

  override def stop() {
    FxToolkit.hideStage()
    jfxAppFixture.stop()
  }

} 
开发者ID:haraldmaida,项目名称:ScalaTestFX,代码行数:26,代码来源:JFXAppAdapter.scala

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: InitialConfiguration

//设置package包名称以及导入依赖的类
package rssidiot
import scalafx.application.JFXApp
import java.io.File
object InitialConfiguration {
  def initEnvironment {
    System.setProperty("http.agent", "Rssidiot/0.1" + " (Ubuntu; U; en)")
    Utility.makeSureFolderExists(Utility.defaultDataFolder)
    JFXApp.userAgentStylesheet = "theme/theme.css"
  }
  def initFeedDatabase: FeedDatabase =
    if (new File(Utility.defaultFeedDatabaseFile).exists) {
      val db = FeedDatabase.loadFrom(Utility.defaultFeedDatabaseFile)
      db.fetchAllNewArticles
      db
    } else
      new FeedDatabase
} 
开发者ID:matthhan,项目名称:rssidiot,代码行数:18,代码来源:InitialConfiguration.scala


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