borderPane中从LeftPane更改CenterPane

borderPane中从LeftPane更改CenterPane

本文介绍了如何在javaFx borderPane中从LeftPane更改CenterPane?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在javafx中创建一个面板,并且我习惯将边框窗格作为主场景。中央面板有4个窗口(main1,main2,main3,main4),左侧面板中有一个导航菜单。

I am trying to make a panel in javafx and i used to a border pane as a main scene. There are 4 windows (main1, main2, main3,main4) for center panel, and there is a navigation menu in left panel.

borderPane.setCenter(mainMenu1.getCenterMain1UI());
//borderPane.setCenter(mainMenu2.getCenterMain2UI());
//borderPane.setCenter(mainMenu3.getCenterMain3UI());
//borderPane.setCenter(mainMenu4.getCenterMain4UI());


public BorderPane getAppWindow(){

    if (borderPane == null){

        borderPane = new BorderPane();
        borderPane.setTop(topPanel.getTopPanelUI());
        borderPane.setBottom(bottomPanel.getBottomPanelUI());
        borderPane.setLeft(leftPanel.getLeftPanelUI());

        borderPane.setCenter(mainMenu.getCenterMainUI());
        borderPane.setAlignment(borderPane.getCenter(), Pos.TOP_LEFT);

    }

    return borderPane;
}

左边面板控制器中的

in the left panel controller

 public class LeftPanelController {

        public VBox leftPanelPane;

        public Button btnLeftPanelMainmenu;
        public Button btnLeftPanelDb;
        public Button btnLeftPanelOfficeInfo;
        public Button btnLeftPanelConfiguration;



        public void btnLeftPanelMainmenuOnClickAction(ActionEvent e){
            change border pane center to main
        }

        public void btnLeftPanelDbOnClickAction(ActionEvent e){
            change border pane center to DB
        }

        public void btnLeftPanelOfficeInfoOnClickAction(ActionEvent e){
            change border pane center to DB
        }

        public void btnLeftPanelConfigurationOnClickAction(ActionEvent e){
            change border pane center to configuration
        }

    }


推荐答案

我改变了左侧面板中的按钮点击方法;

I changed my button click methods in the left panel like that;

    public void btnLeftPanelMainmenuOnClickAction(ActionEvent e) {
        AppWindow.borderPane.setCenter(AppWindow.mainMenu.getCenterMainUI());
    }

    public void btnLeftPanelDbOnClickAction(ActionEvent e) {
        AppWindow.borderPane.setCenter(AppWindow.dbMenu.getCenterDbUI());
    }

    public void btnLeftPanelConfigurationOnClickAction(ActionEvent e) {
        AppWindow.borderPane.setCenter(AppWindow.configMenu.getCenterConfigurationUI());
    }

这篇关于如何在javaFx borderPane中从LeftPane更改CenterPane?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 17:56