配置面板的垂直菜单 [英] Vertical menu for configuration panel

查看:114
本文介绍了配置面板的垂直菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想像这个例子一样创建配置面板:

I would like to create configuration panel like this example:

问题是我不知道如何在左侧创建垂直菜单。你能给出类似菜单的一些例子吗?

The problem is that I don't how to create the vertical menu at the left side. Can you give some example of similar menu?

推荐答案

package verticalmenubar;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Accordion;
import javafx.scene.control.Button;
import javafx.scene.control.TabPane;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
 *
 * @author reegan
 */
public class VerticalMenuBar extends Application {
    public static TabPane tabPanel;
    @Override
    public void start(Stage primaryStage) {
        BorderPane root = buildView();
        Scene scene = new Scene(root, 300, 250);        
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    BorderPane buildView() {
        BorderPane root = new BorderPane();
        tabPanel = new TabPane();
        root.setCenter(tabPanel);
        Accordion accordion = new Accordion();
        Pane pane = null;
        TitledPane tiledPane;
        General1Bar general1 = new General1Bar();
        pane= general1.getView();
        tiledPane = new TitledPane("General1", pane);
        accordion.getPanes().add(tiledPane);

        General2Bar general2 = new General2Bar();
        pane = general2.getView();
         tiledPane = new TitledPane("General2", pane);
        accordion.getPanes().add(tiledPane);

        General3Bar general3 = new General3Bar();
        pane = general3.getView();
        tiledPane = new TitledPane("General3", pane);
        accordion.getPanes().add(tiledPane);

        root.setLeft(accordion);
        return root;
    }



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

class General1Bar {

    public Pane getView() {
        Pane p = new Pane();
        Button button = new Button("One");
        Button button1 = new Button("Two");
        VBox vBox = new VBox(5);
        vBox.getChildren().addAll(button,button1);
        p.getChildren().addAll(vBox);
        return p;
    }

}

class General2Bar {
     public Pane getView() {
        Pane p = new Pane();
        Button button = new Button("One");
        Button button1 = new Button("Two");
        VBox vBox = new VBox(5);
        vBox.getChildren().addAll(button,button1);
        p.getChildren().addAll(vBox);
        return p;
    }

}

class General3Bar {
    public Pane getView() {
        Pane p = new Pane();
        Button button = new Button("One");
        Button button1 = new Button("Two");
        VBox vBox = new VBox(5);
        vBox.getChildren().addAll(button,button1);
        p.getChildren().addAll(vBox);
        return p;
    }
}

我是javafx的新成员。如果有任何错误,请检查此代码告诉我..

I am newly in javafx. please check this code if any wrong is there tell me..

这篇关于配置面板的垂直菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆