Created
August 16, 2013 08:32
-
-
Save rabitarochan/6248256 to your computer and use it in GitHub Desktop.
ScalaFxでAnchorPaneの記述を他のものと揃えるためのtrait。
This file contains hidden or 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
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) | |
} | |
} |
This file contains hidden or 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
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