Skip to content

Instantly share code, notes, and snippets.

Created March 10, 2017 16:27
Show Gist options
  • Save anonymous/6c073dbf232e5ef560b070bc86ff7234 to your computer and use it in GitHub Desktop.
Save anonymous/6c073dbf232e5ef560b070bc86ff7234 to your computer and use it in GitHub Desktop.
How in the JRuby..
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TreeView;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
MainItem i1 = new MainItem("Worlds");
MainItem i2 = new MainItem("Planets");
MainItem itemGroup = new MainItem("Hello");
itemGroup.getChildren().addAll(i1, i2);
TreeView allItems = new TreeView(itemGroup);
Label someLabel = new Label();
AnchorPane root = new AnchorPane();
root.getChildren().addAll(allItems, someLabel);
AnchorPane.setBottomAnchor(someLabel, 5.0);
AnchorPane.setLeftAnchor(someLabel, 5.0);
someLabel.textProperty().bind(Bindings.selectString(allItems.getSelectionModel().selectedItemProperty(), "plats"));
primaryStage.setTitle("Hello Universe");
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.TreeItem;
public class MainItem extends TreeItem {
public StringProperty plats = new SimpleStringProperty();
public String getPlats() {
return plats.get();
}
public StringProperty platsProperty() {
return plats;
}
public void setPlats(String appTitle) {
this.plats.set(appTitle);
}
public MainItem(String x) {
super(x);
setPlats("oh look.. " + x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment