javafx.scene.layout.Pane Java Examples

The following examples show how to use javafx.scene.layout.Pane. 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: ArenaCoursesSlide.java    From ShootOFF with GNU General Public License v3.0 6 votes vote down vote up
private Pane buildCoursePanes() {
	final File coursesDirectory = new File(System.getProperty("shootoff.courses"));

	final ItemSelectionPane<File> uncategorizedPane = buildCategoryPane(coursesDirectory);
	coursePanes.getChildren().add(new TitledPane("Uncategorized Courses", uncategorizedPane));
	categoryMap.put(coursesDirectory.getPath(), uncategorizedPane);

	final File[] courseFolders = coursesDirectory.listFiles(FOLDER_FILTER);

	if (courseFolders != null) {
		for (final File courseFolder : courseFolders) {
			coursePanes.getChildren().add(new TitledPane(courseFolder.getName().replaceAll("_", "") + " Courses",
					buildCategoryPane(courseFolder)));
		}
	} else {
		logger.error("{} does not appear to be a valid course directory", coursesDirectory.getPath());
	}

	return coursePanes;
}
 
Example #2
Source File: TradesChartsView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void layout() {
    UserThread.runAfter(() -> {
        double available;
        if (root.getParent() instanceof Pane)
            available = ((Pane) root.getParent()).getHeight();
        else
            available = root.getHeight();

        available = available - volumeChartPane.getHeight() - toolBox.getHeight() - nrOfTradeStatisticsLabel.getHeight() - 75;
        if (priceChart.isManaged())
            available = available - priceChartPane.getHeight();
        else
            available = available + 10;
        tableView.setPrefHeight(available);
    }, 100, TimeUnit.MILLISECONDS);
}
 
Example #3
Source File: PortHardwareCounters.java    From trex-stateless-gui with Apache License 2.0 6 votes vote down vote up
private void update() {
    try {
        if (savedXStatsNames == null) {
            savedXStatsNames = ConnectionManager.getInstance().sendPortXStatsNamesRequest(port);
        }
        String xStatsValues = ConnectionManager.getInstance().sendPortXStatsValuesRequest(port);
        Map<String, Long> loadedXStatsList = Util.getXStatsFromJSONString(savedXStatsNames, xStatsValues);
        port.setXstats(loadedXStatsList);
        Pane pane = statsTableGenerator.generateXStatPane(true, port, statXTableNotEmpty.isSelected(), statXTableFilter.getText(), resetCountersRequested);
        statXTableContainer.setContent(pane);
        statXTableContainer.setVisible(true);
        if (resetCountersRequested) {
            resetCountersRequested = false;
        }
    } catch (Exception ignored) {
    }
}
 
Example #4
Source File: XYZPane.java    From charts with Apache License 2.0 6 votes vote down vote up
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    getStyleClass().setAll("chart", "xyz-chart");

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();

    pane = new Pane(canvas);

    getChildren().setAll(pane);
}
 
Example #5
Source File: TitleBar.java    From desktoppanefx with Apache License 2.0 6 votes vote down vote up
private Pane makeTitlePane(String title) {
    HBox hbLeft = new HBox();
    hbLeft.setSpacing(10d);
    lblTitle = new Label();
    lblTitle.textProperty().bind(titleProperty());
    setTitle(title);
    lblTitle.getStyleClass().add("internal-window-titlebar-title");

    if (icon != null) { hbLeft.getChildren().add(icon); }
    hbLeft.getChildren().add(lblTitle);
    hbLeft.setAlignment(Pos.CENTER_LEFT);
    AnchorPane.setLeftAnchor(hbLeft, 10d);
    AnchorPane.setBottomAnchor(hbLeft, 0d);
    AnchorPane.setRightAnchor(hbLeft, 20d);
    AnchorPane.setTopAnchor(hbLeft, 0d);
    return hbLeft;
}
 
Example #6
Source File: LoadingScreenDemo.java    From FXTutorials with MIT License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("ui.fxml"));
    loader.setController(this);

    Pane root = loader.load();

    primaryStage.setScene(new Scene(root));
    primaryStage.show();

    progressBar.progressProperty().bind(task.progressProperty());

    loadingCircleAnimation.play();

    Thread t = new Thread(task);
    t.start();
}
 
Example #7
Source File: Plugin.java    From exit_code_java with GNU General Public License v3.0 6 votes vote down vote up
public static void createAppWindow() {
    //Create a new window
    WindowBuilder window = new WindowBuilder("jSnake");
    window.setPrefSize(450, 350); // Window Size (Width, height)
    window.setProcessName("jsnake.app");

    //App
    Pane browserRoot = new Pane();
    window.setCenter(browserRoot);

    WebView browser = new WebView();
    browser.prefWidthProperty().bind(browserRoot.widthProperty());
    browser.prefHeightProperty().bind(browserRoot.heightProperty());
    browserRoot.getChildren().add(browser);
    
    WebEngine webEngine = browser.getEngine();
    try {
        webEngine.load((Plugin.class.getResource("/web/index.html")).toString());
    } catch(Exception e) {}
    
    //Spawn the window
    window.spawnWindow();
    window.placeApp();
}
 
Example #8
Source File: XYPlotRepresentation.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Pane createJFXNode() throws Exception
{
    // Plot is only active in runtime mode, not edit mode
    plot = new RTValuePlot(! toolkit.isEditMode());
    plot.setUpdateThrottle(Preferences.plot_update_delay, TimeUnit.MILLISECONDS);
    plot.showToolbar(false);
    plot.showCrosshair(false);
    plot.setManaged(false);

    // Create PlotMarkers once. Not allowing adding/removing them at runtime
    if (! toolkit.isEditMode())
        for (MarkerProperty marker : model_widget.propMarkers().getValue())
            createMarker(marker);

    // Add button to reset ranges of X and Y axes to the values when plot was first rendered.
    Button resetAxisRanges =
            plot.addToolItem(JFXUtil.getIcon("reset_axis_ranges.png"), Messages.Reset_Axis_Ranges);

    resetAxisRanges.setOnMouseClicked(me -> {
        plot.resetAxisRanges();
    });

    return plot;
}
 
Example #9
Source File: CircleProperties.java    From UndoFX with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    Pane pane = new Pane();
    pane.setPrefWidth(400);
    pane.setPrefHeight(400);
    pane.getChildren().add(circle);

    HBox undoPanel = new HBox(20.0, undoBtn, redoBtn, saveBtn);

    VBox root = new VBox(10.0,
            pane,
            labeled("Color", colorPicker),
            labeled("Radius", radius),
            labeled("X", centerX),
            labeled("Y", centerY),
            undoPanel);
    root.setAlignment(Pos.CENTER);
    root.setFillWidth(false);

    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example #10
Source File: DeckBuilderWindow.java    From Cardshifter with Apache License 2.0 6 votes vote down vote up
private void displayActiveDeck() {
	this.activeDeckBox.getChildren().clear();
	List<String> sortedKeys = new ArrayList<>(this.activeDeckConfig.getChosen().keySet());
	Collections.sort(sortedKeys);
	for (String cardId : sortedKeys) {
		if (!cardList.containsKey(cardId)) {
			activeDeckConfig.setChosen(cardId, 0);
			continue;
		}
		DeckCardController card = new DeckCardController(this.cardList.get(cardId), this.activeDeckConfig.getChosen().get(cardId));
		Pane cardPane = card.getRootPane();
		cardPane.setOnMouseClicked(e -> {this.removeCardFromDeck(e, cardId);});
		this.activeDeckBox.getChildren().add(cardPane);
	}
	this.cardCountLabel.setText(String.format("%d / %d", this.activeDeckConfig.total(), this.activeDeckConfig.getMaxSize()));
}
 
Example #11
Source File: MoleculeViewSkin.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void releaseGlassPane()
{
    dragCanvas.setVisible(false);
    dragCanvas = null;

    if (glassPane != null) {
        if (rootNode.getScene() != null) {
            final Parent parent = rootNode.getScene().getRoot();
            if (parent instanceof Pane) {
                Pane p = (Pane) parent;
                p.getChildren().remove(glassPane);

                glassPane.setOnDragOver(null);
                glassPane.setOnDragDropped(null);
                glassPane = null;
            }
        }
    }
}
 
Example #12
Source File: MainApp.java    From Motion_Profile_Generator with MIT License 6 votes vote down vote up
@Override
public void start( Stage primaryStage )
{
    try
    {
        Pane root = FXMLLoader.load( getClass().getResource("/com/mammen/ui/javafx/main/MainUI.fxml") );
        root.autosize();

        primaryStage.setScene( new Scene( root ) );
        primaryStage.sizeToScene();
        primaryStage.setTitle("Motion Profile Generator");
        primaryStage.setMinWidth( 1280 ); //1170
        primaryStage.setMinHeight( 720 ); //790
        primaryStage.setResizable( true );

        primaryStage.show();
    }
    catch( Exception e )
    {
        e.printStackTrace();
    }
}
 
Example #13
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
/**
	 * Create the desktop swing node
	 */
	private void createDesktopNode() {
		// Create group to hold swingNode which in turns holds the Swing desktop
		desktopNode = new SwingNode();
		// desktopNode.setStyle("-fx-background-color: black; ");
		desktop = new MainDesktopPane(this);
		desktopNode.setStyle("-fx-background-color: transparent; -fx-border-color: black; ");	
		desktopPane = new Pane(desktopNode);
		desktopPane.setMaxSize(screen_width - 25, screen_height); // TAB_PANEL_HEIGHT

		// Add main pane
		WebPanel mainPane = new WebPanel(new BorderLayout());
		mainPane.setSize(screen_width - 25 , screen_height - 15);
		mainPane.add(desktop, BorderLayout.CENTER);	
//		desktopNode.setContent(mainPane);
		SwingUtilities.invokeLater(() -> desktopNode.setContent(mainPane));

//		desktopNode.requestFocus();
	}
 
Example #14
Source File: Main.java    From thundernetwork with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Loads the FXML file with the given name, blurs out the main UI and puts this one on top.
 */
public <T> OverlayUI<T> overlayUI (String name) {
    try {
        checkGuiThread();
        // Load the UI from disk.
        URL location = GuiUtils.getResource(name);
        FXMLLoader loader = new FXMLLoader(location);
        Pane ui = loader.load();
        T controller = loader.getController();
        OverlayUI<T> pair = new OverlayUI<T>(ui, controller);
        // Auto-magically set the overlayUI member, if it's there.
        try {
            if (controller != null) {
                controller.getClass().getField("overlayUI").set(controller, pair);
            }
        } catch (IllegalAccessException | NoSuchFieldException ignored) {
            ignored.printStackTrace();
        }
        pair.show();
        return pair;
    } catch (IOException e) {
        throw new RuntimeException(e);  // Can't happen.
    }
}
 
Example #15
Source File: GuiUtils.java    From thundernetwork with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void runAlert(BiConsumer<Stage, AlertWindowController> setup) {
    try {
        // JavaFX2 doesn't actually have a standard alert template. Instead the Scene Builder app will create FXML
        // files for an alert window for you, and then you customise it as you see fit. I guess it makes sense in
        // an odd sort of way.
        Stage dialogStage = new Stage();
        dialogStage.initModality(Modality.APPLICATION_MODAL);
        FXMLLoader loader = new FXMLLoader(GuiUtils.class.getResource("alert.fxml"));
        Pane pane = loader.load();
        AlertWindowController controller = loader.getController();
        setup.accept(dialogStage, controller);
        dialogStage.setScene(new Scene(pane));
        dialogStage.showAndWait();
    } catch (IOException e) {
        // We crashed whilst trying to show the alert dialog (this should never happen). Give up!
        throw new RuntimeException(e);
    }
}
 
Example #16
Source File: ResponderApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
  Pane root = (Pane) FXMLLoader.load(getClass().getResource("layout_responder_app.fxml"));
  Scene scene = new Scene(root, -1, -1);
  scene.getStylesheets().add("main.css");
  stage.setTitle("Responder App");
  stage.initStyle(StageStyle.TRANSPARENT);
  stage.setScene(scene);
  stage.setMaximized(true);
  stage.show();
}
 
Example #17
Source File: TopsoilPlotWetherill.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
@Override
public Pane initializePlotPane() {
    TopsoilPlotController.setTopsoilPlot(this);
    Pane topsoilPlotUI = null;
    try {
        topsoilPlotUI = FXMLLoader.load(getClass().getResource("TopsoilPlot.fxml"));
    } catch (IOException iOException) {
    }

    return topsoilPlotUI;
}
 
Example #18
Source File: ChatListStage.java    From oim-fx with MIT License 5 votes vote down vote up
private Cursor getCursor(MouseEvent me, Pane pane) {
	Cursor cursor = Cursor.DEFAULT;

	double grp = 3;
	double width = pane.getWidth();
	double height = pane.getHeight();

	double x = me.getX();
	double y = me.getY();

	if (x < grp && y < grp) {
		// cursor = Cursor.SE_RESIZE;
		type = 1;
	} else if (x > (width - grp) && y < grp) {
		// cursor = Cursor.SW_RESIZE;
		type = 2;
	} else if (x < grp && y > (height - grp)) {
		// cursor = Cursor.SW_RESIZE;
		type = 3;
	} else if (x > (width - grp) && y > (height - grp)) {
		// cursor = Cursor.SE_RESIZE;
		type = 4;
	} else if (x < grp) {
		// cursor = Cursor.H_RESIZE;
		type = 5;
	} else if (x > (width - grp)) {
		cursor = Cursor.H_RESIZE;
		type = 6;
	} else if (y < grp) {
		// cursor = Cursor.V_RESIZE;
		type = 7;
	} else if (y > (height - grp)) {
		// cursor = Cursor.V_RESIZE;
		type = 8;
	} else {
		type = 0;
	}
	return cursor;
}
 
Example #19
Source File: TabsRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void updateChanges()
{
    super.updateChanges();

    if (dirty_layout.checkAndClear())
    {
        final String style = JFXUtil.shadedStyle(model_widget.propBackgroundColor().getValue());

        final Background background = new Background(new BackgroundFill(JFXUtil.convert(model_widget.propBackgroundColor().getValue()), null, null));

        for (Tab tab : jfx_node.getTabs())
        {   // Set the font of the 'graphic' that's used to represent the tab
            final Label label = (Label) tab.getGraphic();
            label.setFont(tab_font);

            // Set colors
            tab.setStyle(style);

            final Pane content  = (Pane) tab.getContent();
            content.setBackground(background);
        }

        final Integer width = model_widget.propWidth().getValue();
        final Integer height = model_widget.propHeight().getValue();
        jfx_node.setPrefSize(width, height);
        jfx_node.setTabMinHeight(model_widget.propTabHeight().getValue());

        refreshHack();
    }
}
 
Example #20
Source File: SettingsView.java    From Schillsaver with MIT License 5 votes vote down vote up
private Pane createControlRow(final @NonNull Button button, final @NonNull TextField field) {
    final HBox hBox = new HBox(button, field);
    VBox.setVgrow(hBox, Priority.ALWAYS);

    HBox.setHgrow(button, Priority.NEVER);
    HBox.setHgrow(field, Priority.ALWAYS);

    button.setMinWidth(256);

    return hBox;
}
 
Example #21
Source File: MeterRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Pane createJFXNode() throws Exception
{
    meter = new RTMeter();
    meter.setLimitColors(JFXUtil.convert(WidgetColorService.getColor(NamedWidgetColors.ALARM_MINOR)),
                         JFXUtil.convert(WidgetColorService.getColor(NamedWidgetColors.ALARM_MAJOR)));


    meter.setManaged(false);
    // Wrapper pane (managed) to get alarm-sensitive border
    return new Pane(meter);
}
 
Example #22
Source File: Transitions.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public void fadeOutAndRemove(Node node, int duration, EventHandler<ActionEvent> handler) {
    FadeTransition fade = fadeOut(node, getDuration(duration));
    fade.setInterpolator(Interpolator.EASE_IN);
    fade.setOnFinished(actionEvent -> {
        ((Pane) (node.getParent())).getChildren().remove(node);
        //Profiler.printMsgWithTime("fadeOutAndRemove");
        if (handler != null)
            handler.handle(actionEvent);
    });
}
 
Example #23
Source File: GuiUtils.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
public static Animation fadeOutAndRemove(Duration duration, Pane parentPane, Node... nodes) {
    nodes[0].setCache(true);
    FadeTransition ft = new FadeTransition(duration, nodes[0]);
    ft.setFromValue(nodes[0].getOpacity());
    ft.setToValue(0.0);
    ft.setOnFinished(actionEvent -> parentPane.getChildren().removeAll(nodes));
    ft.play();
    return ft;
}
 
Example #24
Source File: DragAndDropHandler.java    From FxDock with Apache License 2.0 5 votes vote down vote up
protected static Stage createDragWindow(FxDockPane client)
{
	Window owner = FX.getParentWindow(client);
	Image im = createDragImage(client);
	Pane p = new Pane(new ImageView(im));
	Stage s = new Stage(StageStyle.TRANSPARENT);
	s.initOwner(owner);
	s.setScene(new Scene(p, im.getWidth(), im.getHeight()));
	s.setOpacity(DRAG_WINDOW_OPACITY);
	return s;
}
 
Example #25
Source File: ErlyBerly.java    From erlyberly with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Show a new control in the tab pane. The tab is closable.
 */
public static void showPane(String title, Pane parentControl) {
    assert Platform.isFxApplicationThread();
    Tab newTab;
    newTab = new Tab(title);
    newTab.setContent(parentControl);
    addAndSelectTab(newTab);
}
 
Example #26
Source File: Slide.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
private void show(Pane parentContainer, List<Node> slideList, List<Node> savedList) {
	// Do not show twice
	if (!savedList.isEmpty()) return;

	savedList.addAll(parentContainer.getChildren());
	parentContainer.getChildren().setAll(slideList);
}
 
Example #27
Source File: TopsoilPlotEvolution.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
@Override
public Pane initializePlotPane() {
    TopsoilPlotController.setTopsoilPlot(this);
    Pane topsoilPlotUI = null;
    try {
        topsoilPlotUI = FXMLLoader.load(getClass().getResource("TopsoilPlot.fxml"));
    } catch (IOException iOException) {
    }

    return topsoilPlotUI;
}
 
Example #28
Source File: ErlyBerly.java    From erlyberly with GNU General Public License v3.0 5 votes vote down vote up
/**
 * All I know is pane.
 */
public static Pane wrapInPane(Node node) {
    if(node instanceof Pane)
        return (Pane) node;
    VBox.setVgrow(node, Priority.ALWAYS);
    VBox vBox = new VBox(node);
    return vBox;
}
 
Example #29
Source File: Utils.java    From Cryogen with GNU General Public License v2.0 5 votes vote down vote up
private static List<Node> recurse(List<Node> children) {
    List<Node> output = new ArrayList<Node>();
    for (Node obj : children) {
        if (obj instanceof Pane) {
            output.addAll(recurse(((Pane)obj).getChildren()));
        } else {
            output.add(obj);
        }
    }
    return output;
}
 
Example #30
Source File: StyledTextField.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Node traverse( Parent p, Node from, int dir )
{
    if ( p == null ) return null;

    List<Node> nodeList = p.getChildrenUnmodifiable();
    int len = nodeList.size();
    int neighbor = -1;
    
    if ( from != null ) while ( ++neighbor < len && nodeList.get(neighbor) != from );
    else if ( dir == 1 ) neighbor = -1;
    else neighbor = len;
    
    for ( neighbor += dir; neighbor > -1 && neighbor < len; neighbor += dir ) {

        Node target = nodeList.get( neighbor );

        if ( target instanceof Pane || target instanceof Group ) {
            target = traverse( (Parent) target, null, dir ); // down
            if ( target != null ) return target;
        }
        else if ( target.isVisible() && ! target.isDisabled() && target.isFocusTraversable() ) {
            target.requestFocus();
            return target;
        }
    }

    return traverse( p.getParent(), p, dir ); // up
}