Skip to content

Instantly share code, notes, and snippets.

@rabitarochan
Created August 16, 2013 08:32
Show Gist options
  • Save rabitarochan/6248256 to your computer and use it in GitHub Desktop.
Save rabitarochan/6248256 to your computer and use it in GitHub Desktop.
ScalaFxでAnchorPaneの記述を他のものと揃えるためのtrait。
package scalafx.scene.layout
import scalafx.scene.Node
trait InAnchorPane { self: Node =>
def topAnchor: Double = AnchorPane.getTopAnchor(self)
def topAnchor_=(v: Double) {
AnchorPane.setTopAnchor(self, v)
}
def bottomAnchor: Double = AnchorPane.getBottomAnchor(self)
def bottomAnchor_=(v: Double) {
AnchorPane.setBottomAnchor(self, v)
}
def leftAnchor: Double = AnchorPane.getLeftAnchor(self)
def leftAnchor_=(v: Double) {
AnchorPane.setLeftAnchor(self, v)
}
def rightAnchor: Double = AnchorPane.getRightAnchor(self)
def rightAnchor_=(v: Double) {
AnchorPane.setRightAnchor(self, v)
}
}
package app
import scalafx.application.JFXApp
import scalafx.scene.Scene
import scalafx.scene.layout.{InAnchorPane, AnchorPane}
import scalafx.scene.control.TextField
object MyApplication extends JFXApp {
stage = new JFXApp.PrimaryStage {
title = "My Application"
scene = new Scene(
new AnchorPane {
prefWidth = 320
prefHeight = 138
content = List(
new TextField with InAnchorPane {
topAnchor = 18
leftAnchor = 30
rightAnchor = 30
}
)
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment