Java Code Examples for javafx.scene.layout.BorderPane#setPrefWidth()

The following examples show how to use javafx.scene.layout.BorderPane#setPrefWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HelpBox.java    From scenic-view with GNU General Public License v3.0 7 votes vote down vote up
public HelpBox(final String title, final String url, final double x, final double y) {
    final BorderPane pane = new BorderPane();
    pane.setId(StageController.FX_CONNECTOR_BASE_ID + "HelpBox");
    pane.setPrefWidth(SCENE_WIDTH);
    pane.setPrefHeight(SCENE_HEIGHT);
    final ProgressWebView wview = new ProgressWebView();
    wview.setPrefHeight(SCENE_HEIGHT);
    wview.setPrefWidth(SCENE_WIDTH);
    wview.doLoad(url);
    pane.setCenter(wview);
    final Scene scene = new Scene(pane, SCENE_WIDTH, SCENE_HEIGHT); 
    stage = new Stage();
    stage.setTitle(title);
    stage.setScene(scene);
    stage.getIcons().add(HELP_ICON);
    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {

        @Override public void handle(final WindowEvent arg0) {
            DisplayUtils.showWebView(false);
        }
    });
    stage.show();
}
 
Example 2
Source File: MusicPlayer.java    From MusicPlayer with MIT License 6 votes vote down vote up
/**
 * Initializes the main layout.
 */
private void initMain() {
    try {
        // Load main layout from fxml file.
        FXMLLoader loader = new FXMLLoader(this.getClass().getResource(Resources.FXML + "Main.fxml"));
        BorderPane view = loader.load();

        // Shows the scene containing the layout.
        double width = stage.getScene().getWidth();
        double height = stage.getScene().getHeight();

        view.setPrefWidth(width);
        view.setPrefHeight(height);

        Scene scene = new Scene(view);
        stage.setScene(scene);

        // Gives the controller access to the music player main application.
        mainController = loader.getController();
        mediaPlayer.volumeProperty().bind(mainController.getVolumeSlider().valueProperty().divide(200));

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example 3
Source File: MarathonFileChooser.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public Parent getContentPane() {
    BorderPane root = new BorderPane();

    root.getStyleClass().add("MarathonFileChooser");
    root.setId("marathon-file-chooser");
    if (doesAllowChildren) {
        if (!fileChooserInfo.isFileCreation()) {
            propertiesView = new AddPropertiesView(new TestPropertiesInfo(fileChooserInfo.getFileToSave()));
            TitledPane titledPane = new TitledPane("Properties", propertiesView);
            centerPane.getChildren().addAll(splitPane, titledPane);
            root.setPrefWidth(540);
            root.setPrefHeight(580);
        } else {
            root.setPrefWidth(540);
            root.setPrefHeight(380);
            centerPane.getChildren().addAll(splitPane);
        }
    } else {
        root.setPrefWidth(540);
        root.setPrefHeight(380);
        centerPane.getChildren().add(childrenListView);
    }
    root.setCenter(centerPane);
    root.setBottom(buttonBar);
    return root;
}
 
Example 4
Source File: InternalWindow.java    From desktoppanefx with Apache License 2.0 4 votes vote down vote up
public void detachOrAttachWindow() {
    setDetached(!isDetached());

    if (isDetached()) {
        fireEvent(new InternalWindowEvent(this, InternalWindowEvent.WINDOW_DETACHING));

        Point2D locationOnScreen = this.localToScreen(0, 0);
        detachedWindow.getScene().getStylesheets().setAll(collectStylesheets());

        captureBounds();

        dp = desktopPane.removeInternalWindow(this);

        double width = contentPane.getWidth();
        double height = titleBar.getHeight() + contentPane.getHeight();
        BorderPane bp = new BorderPane();
        bp.setId(getId());
        bp.getStyleClass().addAll(getStyleClass());

        bp.setMinWidth(getMinWidth());
        bp.setMinHeight(getMinHeight());
        bp.setPrefWidth(width);
        bp.setPrefHeight(height);

        bp.setTop(titleBar);
        bp.setCenter(contentPane);
        detachedWindow.getScene().setRoot(bp);

        detachedWindow.addEventHandler(MouseEvent.MOUSE_PRESSED, windowMousePressed);
        detachedWindow.addEventHandler(MouseEvent.MOUSE_MOVED, windowMouseMoved);
        detachedWindow.addEventHandler(MouseEvent.MOUSE_DRAGGED, windowMouseDragged);

        detachedWindow.setX(locationOnScreen.getX());
        detachedWindow.setY(locationOnScreen.getY());

        fireEvent(new InternalWindowEvent(this, InternalWindowEvent.WINDOW_DETACHED));
        detachedWindow.show();

        if (isMaximized()) {
            maximizeDetachedWindow();
        } else {
            bp.setMaxWidth(getMaxWidth());
            bp.setMaxHeight(getMaxHeight());
        }
    } else {
        fireEvent(new InternalWindowEvent(this, InternalWindowEvent.WINDOW_ATTACHING));
        detachedWindow.hide();
        detachedWindow.removeEventHandler(MouseEvent.MOUSE_PRESSED, windowMousePressed);
        detachedWindow.removeEventHandler(MouseEvent.MOUSE_MOVED, windowMouseMoved);
        detachedWindow.removeEventHandler(MouseEvent.MOUSE_DRAGGED, windowMouseDragged);

        setTop(titleBar);
        setCenter(contentPane);

        captureDetachedWindowBounds();

        setPrefSize(previousWidth, previousHeight);

        Bounds boundsInScreen = dp.localToScreen(dp.getBoundsInLocal());
        previousX = Math.max(previousX - boundsInScreen.getMinX(), 0);
        previousY = Math.max(previousY - boundsInScreen.getMinY(), 0);

        double maxX = boundsInScreen.getMaxX() - boundsInScreen.getMinX();
        if (previousX + previousWidth > maxX) {
            previousX = maxX - previousWidth;
        }

        double maxY = boundsInScreen.getMaxY() - boundsInScreen.getMinY();
        if (previousY + previousHeight > maxY) {
            previousY = maxY - previousHeight;
        }

        fireEvent(new InternalWindowEvent(this, InternalWindowEvent.WINDOW_ATTACHED));
        dp.addInternalWindow(this, new Point2D(previousX, previousY));
    }
}
 
Example 5
Source File: ParetoPanel.java    From charts with Apache License 2.0 4 votes vote down vote up
private void init() {
    modelStack = new Stack<>();
    dataDots = new ArrayList<>();
    popup = new ParetoInfoPopup();
    mouseHandler       = this::handleMouseEvents;
    modelStack.push(paretoModel);

    _labelingColor = Color.BLACK;

    _singelSubBarCentered = true;

    initGraphics();
    registerListeners();

    colorThemes = new HashMap<>();
    ArrayList<Color> defaultColorTheme = new ArrayList<>();
    defaultColorTheme.add(Color.BLUE);
    colorThemes.putIfAbsent("Default", defaultColorTheme);

    _valueFontYPosition         = 20;
    _identifierFontYPosition    = 40;
    _pathFontYPositon           = 65;
    _percentageLineDataDotColor = Color.BLACK;
    _percentageLineColor        = Color.BLACK;
    _useCalculatedSubBarColors  = true;
    _smoothPercentageCurve      = false;
    _showSubBars                = true;

    textPane   = new AnchorPane();

    yAxisLeft  = Helper.createLeftAxis(0, paretoModel.getTotal(), false, 80d);
    yAxisRight = Helper.createRightAxis(0,100,true,80d);

    maxValue   = new DoublePropertyBase(paretoModel.getTotal()) {
        @Override public Object getBean() { return ParetoPanel.this; }
        @Override public String getName() { return "maxValue"; }
    };

    yAxisLeft.setTitle(paretoModel.getTitle());
    yAxisLeft.setTitleFontSize(30);

    //yAxisRight.setTitle("Percentage"); //title written into the numbers of scale
    yAxisRight.setTitleFontSize(30);

    yAxisRight.setUnit("\\u0025");

    yAxisLeft.maxValueProperty().bindBidirectional(maxValue);

    yAxisRight.setPosition(Position.CENTER);
    bPane = new BorderPane();
    bPane.setPrefWidth(yAxisRight.getWidth()+ canvas.getWidth()+ yAxisRight.getWidth());
    bPane.setCenter(canvas);

    yAxisRightProperty = new ObjectPropertyBase<Axis>(yAxisRight) {
        @Override public Object getBean() { return ParetoPanel.this; }
        @Override public String getName() { return "yAxisRight"; }
    };
    yAxisLeftProperty  = new ObjectPropertyBase<Axis>(yAxisLeft) {
        @Override public Object getBean() { return ParetoPanel.this; }
        @Override public String getName() { return "yAxisLeft"; }
    };

    bPane.rightProperty().bind(yAxisRightProperty);
    bPane.leftProperty().bind(yAxisLeftProperty);

    _barSpacing = 5;

    width  = getWidth() - getInsets().getLeft() - getInsets().getRight();
    height = getHeight() - getInsets().getTop() - getInsets().getBottom();
    bPane.setMaxSize(width, height);
    bPane.setPrefSize(width, height);

    canvas.setWidth(width-yAxisRight.getWidth()-yAxisLeft.getWidth());

    textPane.setMaxHeight(80);
    textPane.setMinHeight(80);

    StackPane test = new StackPane();
    test.setPrefHeight(80d);
    labelingCanvas = new Canvas();

    labelingCanvas.setHeight(80);
    labelingCtx = labelingCanvas.getGraphicsContext2D();

    delayRedraw = false;

    bPane.setBottom(labelingCanvas);

    getChildren().setAll(bPane);

    drawParetoChart();
}