In Javafx the DisclosureNode of Treeview is on left by default. How can I I place the Disclosure Node to Right (float right)..?? Any Help would be appreciated.
Asked
Active
Viewed 664 times
2
-
1What is DisclosureNode? – Uluk Biy Sep 22 '15 at 06:35
-
@UlukBiy It's the "expand/collapse" icon: http://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TreeCell.html#disclosureNodeProperty – James_D Sep 22 '15 at 11:12
1 Answers
1
You only need to set the Node Orientation to get a right to left behaviour. But be aware of, that all childrens of this TreeView will inherit the orientation as a default.
import javafx.application.Application;
import javafx.geometry.NodeOrientation;
import javafx.scene.Scene;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class TreeViewRightLeft extends Application {
@Override
public void start(Stage primaryStage) {
TreeItem<String> item = new TreeItem<>("Root Node");
item.setExpanded(true);
item.getChildren().addAll(
new TreeItem<>("Item 1"),
new TreeItem<>("Item 2"),
new TreeItem<>("Item 3")
);
TreeView<String> treeView = new TreeView<>(item);
// Here you can select the orientation.
treeView.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
BorderPane root = new BorderPane(treeView);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("TreeView");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Right to Left
Left to Right (default)

aw-think
- 4,723
- 2
- 21
- 42
-
Hi, Is there any other way without using NodeOrientation. Can we do something with css..? – Vikas Singh Sep 22 '15 at 07:57
-
1@user2396250 can you clarify why does not the node orientation fit for you? – Uluk Biy Sep 22 '15 at 08:10
-
@user2396250 Haven't seen such a CSS class. So probably the answer is No. – aw-think Sep 22 '15 at 08:13