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

The following examples show how to use javafx.scene.layout.BorderPane#setMaxWidth() . 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: HamburgerSlideCloseTransition.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
@Override
protected void starting() {
    super.starting();

    if (node.getParent() instanceof JFXRippler) {
        JFXRippler rippler = (JFXRippler) node.getParent();
        BorderPane p = new BorderPane(node);
        p.setMaxWidth(((JFXHamburger) node).getWidth());
        p.setMinWidth(((JFXHamburger) node).getWidth());
        p.addEventHandler(MouseEvent.ANY, (event) -> {
            if (!event.isConsumed()) {
                event.consume();
                node.fireEvent(event);
            }
        });
        rippler.setControl(p);
    }

    if (this.getRate() == -1) {
        ((JFXHamburger) node).getChildren().get(1).setVisible(true);
    }
}
 
Example 2
Source File: TabController.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private void configureTab(Tab tab, String title, String iconPath, AnchorPane containerPane, URL resourceURL, EventHandler<Event> onSelectionChangedEvent) {
    double imageWidth = 40.0;

    ImageView imageView = new ImageView(new Image(iconPath));
    imageView.setFitHeight(imageWidth);
    imageView.setFitWidth(imageWidth);

    Label label = new Label(title);
    label.setMaxWidth(tabWidth - 20);
    label.setPadding(new Insets(5, 0, 0, 0));
    label.setStyle("-fx-text-fill: black; -fx-font-size: 10pt; -fx-font-weight: bold;");
    label.setTextAlignment(TextAlignment.CENTER);

    BorderPane tabPane = new BorderPane();
    tabPane.setRotate(90.0);
    tabPane.setMaxWidth(tabWidth);
    tabPane.setCenter(imageView);
    tabPane.setBottom(label);

    tab.setText("");
    tab.setGraphic(tabPane);

    tab.setOnSelectionChanged(onSelectionChangedEvent);

    if (containerPane != null && resourceURL != null) {
        try {
            Parent contentView = FXMLLoader.load(resourceURL);
            containerPane.getChildren().add(contentView);
            AnchorPane.setTopAnchor(contentView, 0.0);
            AnchorPane.setBottomAnchor(contentView, 0.0);
            AnchorPane.setRightAnchor(contentView, 0.0);
            AnchorPane.setLeftAnchor(contentView, 0.0);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
Example 3
Source File: CImageDisplay.java    From Open-Lowcode with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {
	inputdata.addInlineActionDataRef(this.inlineactiondataref);
	this.actionmanager = actionmanager;
	SFile thumbnail = getThumbnail(inputdata, datareference);
	if (!thumbnail.isEmpty()) {
		ByteArrayInputStream imagedata = new ByteArrayInputStream(thumbnail.getContent());
		Image image = new Image(imagedata);
		double imagewidth = image.getWidth();
		double imageheight = image.getHeight();
		thumbnailview = new ImageView(image);
		thumbnailview.setFitWidth(imagewidth);
		thumbnailview.setFitHeight(imageheight);
		thumbnailview.setOnMousePressed(actionmanager.getMouseHandler());
		actionmanager.registerInlineAction(thumbnailview, fullimageaction);
		BorderPane border = new BorderPane();
		border.setBorder(new Border(
				new BorderStroke(Color.web("#ddeeff"), BorderStrokeStyle.SOLID, CornerRadii.EMPTY,
						new BorderWidths(3)),
				new BorderStroke(Color.web("#bbccdd"), BorderStrokeStyle.SOLID, CornerRadii.EMPTY,
						new BorderWidths(1))));
		border.setCenter(thumbnailview);
		border.setMaxHeight(imageheight + 6);
		border.setMaxWidth(imagewidth + 6);
		DropShadow ds = new DropShadow();
		ds.setRadius(3.0);
		ds.setOffsetX(1.5);
		ds.setOffsetY(1.5);
		ds.setColor(Color.color(0.2, 0.2, 0.2));
		border.setEffect(ds);
		if (this.islabel) {
			FlowPane thispane = new FlowPane();
			Label thislabel = new Label(label);
			thislabel.setFont(
					Font.font(thislabel.getFont().getName(), FontPosture.ITALIC, thislabel.getFont().getSize()));
			thislabel.setMinWidth(120);
			thislabel.setWrapText(true);
			thislabel.setMaxWidth(120);
			thispane.setRowValignment(VPos.TOP);
			thispane.getChildren().add(thislabel);
			thispane.getChildren().add(border);
			return thispane;
		} else {
			return border;
		}

	}

	return null;
}
 
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));
    }
}