0

我有一个带有 JavaFX 8 的 ControlsFX 8.0.6 的非常简单的示例。

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.geometry.Pos;
import javafx.geometry.Side;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.controlsfx.control.HiddenSidesPane;

public class MainApp extends Application
{

    public Node getPanel(Stage stage)
    {

        StackPane stackPane = new StackPane();
        stackPane.setStyle("-fx-padding: 30");

        HiddenSidesPane pane = new HiddenSidesPane();

        Label content = new Label("Content Node");
        content.setStyle("-fx-background-color: white; -fx-border-color: black;");
        content.setAlignment(Pos.CENTER);
        content.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);

        pane.setContent(content);

        SideNode bottom = new SideNode("Bottom", Side.BOTTOM, pane);
        bottom.setStyle("-fx-background-color: rgba(255,255,0,.25);");
        pane.setBottom(bottom);

        stackPane.getChildren().add(pane);

        return stackPane;
    }

    class SideNode extends Label
    {

        public SideNode(final String text, final Side side,
            final HiddenSidesPane pane)
        {

            super(text + " (Click to pin / unpin)");

            setAlignment(Pos.CENTER);
            setPrefSize(200, 200);
        }
    }

    public static void main(String[] args)
    {
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception
    {

        Scene scene = new Scene((Parent) getPanel(stage));

        stage.setTitle("JavaFX and Maven");
        stage.setScene(scene);
        stage.show();
    }

}

我对如何在 SideNode 上不仅显示文本感兴趣。我想显示不同的布局控件,如 BorderPane 和 VBox。这可能吗?

4

1 回答 1

1

做就是了

BorderPane bottomPane = new BorderPane();
// fill bottomPane with stuff...
pane.setBottom(bottomPane);

或类似地VBox

于 2014-09-04T14:26:53.997 回答