-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import files from scalafx sub-project
scalafx-hello-world
.
- Loading branch information
Showing
6 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ project/plugins/project/ | |
# Scala-IDE specific | ||
.scala_dependencies | ||
.worksheet | ||
|
||
/.idea/ | ||
/project/project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,52 @@ | ||
scalafx-hello-world | ||
=================== | ||
|
||
Simple example of a ScalaFX application | ||
Simple example of a ScalaFX application using [Simple-Build-Tool](http://www.scala-sbt.org/) (SBT). | ||
|
||
Content | ||
------- | ||
|
||
src/main/scala/hello/ScalaFXHelloWorld.scala - sample ScalaFX application. | ||
|
||
build.sbt - the main SBT configuration file. | ||
project/build.properties - version of SBT to use. | ||
project/plugins.sbt - plugins used for creation of IDEA and Eclipse projects. | ||
|
||
|
||
|
||
How to build and Run | ||
-------------------- | ||
|
||
1. Install [Java 7 JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html) | ||
|
||
2. Install [SBT](http://www.scala-sbt.org/) | ||
|
||
3. Run the example: change o directory containing this example and use SBT to | ||
build and run the example: | ||
|
||
%> sbt run | ||
|
||
It will download needed dependencies, including Scala and ScalaFX, and run | ||
the example code. | ||
|
||
|
||
Crete project for IDEA or Eclipse | ||
--------------------------------- | ||
|
||
If you want to create project that can be used with IntelliJ IDEA, inside | ||
this project directory, at command prompt type: | ||
|
||
%> sbt gen-idea | ||
|
||
|
||
If you want to create project that can be used with Eclipse, inside | ||
this project directory, at command prompt type: | ||
|
||
%> sbt eclipse | ||
|
||
|
||
Additional Information | ||
---------------------- | ||
|
||
Detailed description of similar example can be found in the blog post | ||
["Getting Started with ScalaFX: Compile and Run"](http://codingonthestaircase.wordpress.com/2013/05/17/getting-started-with-scalafx-compile-and-run-2/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Name of the project | ||
name := "ScalaFX Hello World" | ||
|
||
// Project version | ||
version := "1.0.8" | ||
|
||
// Version of Scala used by the project | ||
scalaVersion := "2.10.4" | ||
|
||
// Add dependency on ScalaFX library, for use with JavaFX 2.2/Java 7 | ||
libraryDependencies += "org.scalafx" %% "scalafx" % "1.0.0-R8" | ||
|
||
// Add dependency on ScalaFX library, for use with JavaFX 8/Java 8 | ||
// libraryDependencies += "org.scalafx" %% "scalafx" % "8.0.0-M3" | ||
|
||
// Add dependency on JavaFX library (only for Java 7) | ||
unmanagedJars in Compile += Attributed.blank(file(scala.util.Properties.javaHome) / "/lib/jfxrt.jar") | ||
|
||
// Fork a new JVM for 'run' and 'test:run', to avoid JavaFX double initialization problems | ||
fork := true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sbt.version=0.13.5 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
scalacOptions ++= Seq("-unchecked", "-deprecation") | ||
|
||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2011-2013, ScalaFX Project | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* * Neither the name of the ScalaFX Project nor the | ||
* names of its contributors may be used to endorse or promote products | ||
* derived from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE SCALAFX PROJECT OR ITS CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
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.{Stops, LinearGradient} | ||
import scalafx.scene.text.Text | ||
|
||
object ScalaFXHelloWorld extends JFXApp { | ||
|
||
stage = new PrimaryStage { | ||
title = "ScalaFX Hello World" | ||
scene = new Scene { | ||
fill = BLACK | ||
content = new HBox { | ||
padding = Insets(20) | ||
content = Seq( | ||
new Text { | ||
text = "Hello " | ||
style = "-fx-font-size: 100pt" | ||
fill = new LinearGradient( | ||
endX = 0, | ||
stops = Stops(PALEGREEN, SEAGREEN)) | ||
}, | ||
new Text { | ||
text = "World!!!" | ||
style = "-fx-font-size: 100pt" | ||
fill = new LinearGradient( | ||
endX = 0, | ||
stops = Stops(CYAN, DODGERBLUE) | ||
) | ||
effect = new DropShadow { | ||
color = DODGERBLUE | ||
radius = 25 | ||
spread = 0.25 | ||
} | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |