Example usage for javafx.scene.layout StackPane StackPane

List of usage examples for javafx.scene.layout StackPane StackPane

Introduction

In this page you can find the example usage for javafx.scene.layout StackPane StackPane.

Prototype

public StackPane() 

Source Link

Document

Creates a StackPane layout with default CENTER alignment.

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    CheckBoxTreeItem<String> rootItem = new CheckBoxTreeItem<>("A");
    rootItem.setExpanded(true);//from  ww  w  .j av  a  2 s  .c  o m

    TreeView tree = new TreeView(rootItem);
    tree.setEditable(true);

    tree.setCellFactory(CheckBoxTreeCell.forTreeView());

    CheckBoxTreeItem<String> checkBoxTreeItem = new CheckBoxTreeItem<>("a");
    rootItem.getChildren().add(checkBoxTreeItem);

    checkBoxTreeItem = new CheckBoxTreeItem<>("b");
    rootItem.getChildren().add(checkBoxTreeItem);

    tree.setRoot(rootItem);

    StackPane root = new StackPane();
    root.getChildren().add(tree);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    CategoryAxis xAxis = new CategoryAxis();
    NumberAxis yAxis = new NumberAxis();
    BarChart barChart = new BarChart(xAxis, yAxis, getChartData());
    barChart.setCategoryGap(0.2);//from   w w w  . ja v  a  2 s .c o  m
    System.out.println(barChart.getBarGap());
    System.out.println(barChart.getCategoryGap());
    barChart.setTitle("A");
    primaryStage.setTitle("BarChart example");

    StackPane root = new StackPane();
    root.getChildren().add(barChart);
    primaryStage.setScene(new Scene(root, 400, 250));
    primaryStage.show();
}

From source file:gov.va.isaac.gui.util.ErrorMarkerUtils.java

/**
 * @deprecated Use {@link #setupErrorMarker(Control, StackPane, ValidBooleanBinding)} instead
 *///from w  ww . j a v  a  2s. c o m
public static Node setupErrorMarker(Control initialControl, ObservableStringValue reasonWhyControlInvalid) {
    return setupErrorMarker(initialControl, new StackPane(), reasonWhyControlInvalid);
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Checkbox Sample");
    stage.setWidth(230);/*from  w w w. j a  v  a2 s  . c o m*/
    stage.setHeight(120);

    for (int i = 0; i < names.length; i++) {
        final CheckBox cb = cbs[i] = new CheckBox(names[i]);
        cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
            public void changed(ObservableValue ov, Boolean old_val, Boolean new_val) {
                System.out.println(new_val);
            }
        });
    }

    VBox vbox = new VBox();
    vbox.getChildren().addAll(cbs);
    vbox.setSpacing(5);

    HBox hbox = new HBox();
    hbox.setPadding(new Insets(0, 0, 0, 5));

    StackPane stack = new StackPane();
    stack.getChildren().add(hbox);

    HBox root = new HBox();
    root.getChildren().add(vbox);
    root.getChildren().add(stack);
    root.setSpacing(40);
    root.setPadding(new Insets(20, 10, 10, 20));

    ((Group) scene.getRoot()).getChildren().add(root);

    stage.setScene(scene);
    stage.show();
}

From source file:net.sf.mzmine.chartbasics.gui.javafx.demo.FXCategoryChartGestureDemo.java

@Override
public void start(Stage stage) throws Exception {
    JFreeChart chart = ChartFactory.createBarChart("Random", "Category", "value", createDataset());
    EChartViewer canvas = new EChartViewer(chart);
    StackPane stackPane = new StackPane();
    stackPane.getChildren().add(canvas);
    stage.setScene(new Scene(stackPane));
    stage.setTitle("Chart gesture demo");
    stage.setWidth(700);/* w w  w  .j  a  va2  s.  c  o  m*/
    stage.setHeight(390);
    stage.show();
}

From source file:net.sf.mzmine.chartbasics.gui.javafx.demo.FXChartGestureDemo.java

@Override
public void start(Stage stage) throws Exception {
    XYDataset dataset = createDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("Random", "i", "r", createDataset());
    EChartViewer canvas = new EChartViewer(chart);
    StackPane stackPane = new StackPane();
    stackPane.getChildren().add(canvas);
    stage.setScene(new Scene(stackPane));
    stage.setTitle("Chart gesture demo");
    stage.setWidth(700);/* w w  w.java  2 s .c  o  m*/
    stage.setHeight(390);
    stage.show();
}

From source file:net.sf.mzmine.chartbasics.gui.swing.demo.SwingChartGestureDemo.java

public SwingChartGestureDemo() {
    setSize(800, 600);/*from   ww w  . ja v  a2 s  . c  o  m*/
    setTitle("Chart gesture test");
    XYDataset dataset = createDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("Random", "i", "r", createDataset());
    EChartPanel canvas = new EChartPanel(chart);
    StackPane stackPane = new StackPane();
    getContentPane().add(canvas, BorderLayout.CENTER);
}

From source file:net.sf.mzmine.chartbasics.gui.swing.demo.SwingCombinedChartGestureDemo.java

public SwingCombinedChartGestureDemo() {
    setSize(800, 600);/*from   w  ww .j  a v a2s.co m*/
    setTitle("Chart gesture test");
    JFreeChart chart = createCombinedChart();
    EChartPanel canvas = new EChartPanel(chart);
    StackPane stackPane = new StackPane();
    getContentPane().add(canvas, BorderLayout.CENTER);
}

From source file:net.sf.mzmine.chartbasics.gui.javafx.demo.FXCombinedChartGestureDemo.java

@Override
public void start(Stage stage) throws Exception {
    try {//  www  .j  a va 2 s .c  o m
        JFreeChart chart = createCombinedChart();
        EChartViewer canvas = new EChartViewer(chart);
        StackPane stackPane = new StackPane();
        stackPane.getChildren().add(canvas);
        stage.setScene(new Scene(stackPane));
        stage.setTitle("Chart gesture demo");
        stage.setWidth(700);
        stage.setHeight(390);
        stage.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:gov.va.isaac.gui.util.ErrorMarkerUtils.java

/**
 * Setup an 'EXCLAMATION' error marker on the component. Automatically displays anytime that the reasonWhyControlInvalid value
 * is false. Hides when the isControlCurrentlyValid is true.
 * @param stackPane - optional - created if necessary
 *///w  ww .  jav a 2 s. c om
public static StackPane setupErrorMarker(Node initialNode, StackPane stackPane,
        ValidBooleanBinding isNodeCurrentlyValid) {
    ImageView exclamation = Images.EXCLAMATION.createImageView();

    if (stackPane == null) {
        stackPane = new StackPane();
    }

    exclamation.visibleProperty().bind(isNodeCurrentlyValid.not());
    Tooltip tooltip = new Tooltip();
    tooltip.textProperty().bind(isNodeCurrentlyValid.getReasonWhyInvalid());
    Tooltip.install(exclamation, tooltip);
    tooltip.setAutoHide(true);

    exclamation.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            tooltip.show(exclamation, event.getScreenX(), event.getScreenY());

        }

    });

    stackPane.setMaxWidth(Double.MAX_VALUE);
    stackPane.getChildren().add(initialNode);
    StackPane.setAlignment(initialNode, Pos.CENTER_LEFT);
    stackPane.getChildren().add(exclamation);
    StackPane.setAlignment(exclamation, Pos.CENTER_RIGHT);
    double insetFromRight;
    if (initialNode instanceof ComboBox) {
        insetFromRight = 30.0;
    } else if (initialNode instanceof ChoiceBox) {
        insetFromRight = 25.0;
    } else {
        insetFromRight = 5.0;
    }
    StackPane.setMargin(exclamation, new Insets(0.0, insetFromRight, 0.0, 0.0));
    return stackPane;
}