Skip to content

Instantly share code, notes, and snippets.

@mgttlinger
Created February 10, 2014 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgttlinger/943e238cf7b6ab2b631a to your computer and use it in GitHub Desktop.
Save mgttlinger/943e238cf7b6ab2b631a to your computer and use it in GitHub Desktop.
Demonstration for type mismath error
name := "Demonstration"
version := "1.0"
scalaVersion := "2.10.3"
libraryDependencies += "org.scalafx" %% "scalafx" % "1.0.0-M7"
fork in run := true
unmanagedJars in Compile += Attributed.blank(file(System.getenv("JAVA_HOME") + "/jre/lib/jfxrt.jar"))
import javafx.scene.control._
import javafx.scene.image.{Image, ImageView}
import scalafx.Includes._
import javafx.fxml.FXML
import javafx.beans.property.{SimpleBooleanProperty, ReadOnlyListWrapper}
import scalafx.collections.ObservableBuffer
import scalafx.beans.property._
import scalafx.beans.value.ObservableValue
class Controller {
@FXML
var errorTable: TableView[Error] = null
@FXML
var errorMessage: TableColumn[Error, String] = null
@FXML
var errorSource: TableColumn[Error, String] = null
@FXML
var errorFixed: TableColumn[Error, Boolean] = null
val allErrors: ObservableBuffer[Error] = ObservableBuffer(Seq(Error("src","hi", false), Error("src2","Hello", true)))
val allErrorsCol = new ReadOnlyListWrapper(allErrors)
def initialize() = {
errorMessage.cellValueFactory = features => new StringProperty(features.value.message)
errorSource.cellValueFactory = features => new StringProperty(features.value.source)
errorFixed.cellValueFactory = features => ReadOnlyBooleanWrapper(features.value.fixed)//.asInstanceOf[ObservableValue[Boolean, Boolean]]
errorTable.items <== allErrorsCol
}
}
case class Error(source: String, message: String, fixed: Boolean=false)
<?xml version="1.0" encoding="UTF-8"?>
<?import java.net.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<TabPane prefHeight="600.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE" xmlns:fx="http://javafx.com/fxml/1"
xmlns="http://javafx.com/javafx/2.2" fx:controller="Controller">
<Tab text="Errors">
<TableView fx:id="errorTable">
<columns>
<TableColumn fx:id="errorSource" text="Source"/>
<TableColumn fx:id="errorMessage" text="Message"/>
<TableColumn fx:id="errorFixed" text="Fixed"/>
</columns>
</TableView>
</Tab>
</TabPane>
import scalafx.scene.Scene
import scalafx.application.JFXApp
import scalafx.Includes._
import javafx.fxml.FXMLLoader
import javafx.scene.Parent
object Main extends JFXApp {
stage = new JFXApp.PrimaryStage {
title = "Demo"
val stage: Parent = FXMLLoader.load(getClass.getResource("main.fxml"))
scene = new Scene(stage)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment