[EDIT]:私は私の問題を回避行くために管理が、私はまだ良い解決策を探しています。私のソリューションは以下の通りです。CustomTreeItem使用してノードの代わりに、文字列
私は同様のScalaには比較的新しいですScalaFXが、私は前のJavaFXで働いてきました。私はHBoxesを使用するカスタム行でTreeViewを作成しようとしています。
は、これは私が作成したいものです。 Image displaying a TreeView
TreeViewコントロールを文字列として両方のテキストを使用しますが、あなたが見ることができるようにもノード(ステータスバー、ラベル、ハイパーリンク/ボタン)。 TreeItemの値をノードに設定すると、文字列表現を出力するのにtoString関数が使用されますが、実際のノードが表示されます。
String representation of the Node
私は、ToString関数をオーバーライドすることができます知っているが、私はノードがテキストだけではなく、表示したいので、私はこれを一切使用していません。
これは私が一緒に入れ、サンプルコードです:
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.collections.ObservableBuffer
import scalafx.scene.{Scene}
import scalafx.scene.control.{TreeItem, TreeView}
import scalafx.scene.layout.{BorderPane, HBox}
object Launcher extends JFXApp {
case class Picture(path : String, fileSize : Double, isRoot : Boolean,
picChildren : Seq[Picture])
case class PictureRow(picture: Picture) extends HBox
val childList = Seq(
new Picture("/Users/lindberg/Desktop/download.jpeg", 1.4, isRoot = false, Nil),
new Picture("/Users/lindberg/Desktop/image5.jpeg", 0.5, isRoot = false, Nil)
)
val rootList = Seq(
new Picture("/Users/lindberg/Desktop/", 0, isRoot = true, childList)
)
val treeView = new TreeView[PictureRow]() {
root = new TreeItem[PictureRow]() {
children = ObservableBuffer(rootList.map(n => makeTreeItem(n)))
expanded = true
}
showRoot = false
}
val scene = new Scene(800, 400)
scene.root = new BorderPane {
center = treeView
}
stage = new PrimaryStage()
stage.scene = scene
def makeTreeItem(picture : Picture): TreeItem[PictureRow] = {
val item = new TreeItem[PictureRow]() {
children = ObservableBuffer(picture.picChildren.map(n => makeTreeItem(n)))
expanded = true
value = PictureRow(picture)
}
item
}
}
[EDIT]:これは問題の周りに行きました解決策であるが、私はこれでいくつかの助けが欲しいので、それはまだ良い解決策ではありませんもし誰かが興味があれば。
解決方法: 空のStringを返すためにtoString関数をオーバーライドし、TreeItemにグラフィックノードとしてペインを追加しました。このペインには、行に入れたいすべてのノードが表示されました。
解決策を質問に編集しないでください。代わりに、以下の回答を投稿してください。 – Mithrandir
これはそうではないと言います。 [Picture](http://i.imgur.com/i6rnz8K) – lindbergan
これは、最初に提供されなかったような、質問の詳細です。実際の回答がある場合は、回答を投稿してください。ありがとう:) – Mithrandir