/* * =========================================== * Java Pdf Extraction Decoding Access Library * =========================================== * * Project Info: http://www.idrsolutions.com * Help section for developers at http://www.idrsolutions.com/java-pdf-library-support/ * * (C) Copyright 1997-2013, IDRsolutions and Contributors. * * This file is part of JPedal * * @LICENSE@ * * --------------- * MenuExample.java * --------------- */ package menuexample; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.scene.control.ToolBar; import javafx.scene.image.ImageView; import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; /** * This program will create a basic bare-bones stacked Main Menu and ToolBar. * * @author Nathan Howard. */ public class MenuExample extends Application { @Override public void start(Stage primaryStage) { //Setup the VBox Container and BorderPane BorderPane root = new BorderPane(); VBox topContainer = new VBox(); //Setup the Main Menu bar and the ToolBar MenuBar mainMenu = new MenuBar(); ToolBar toolBar = new ToolBar(); //Create SubMenu File. Menu file = new Menu("File"); MenuItem openFile = new MenuItem("Open File"); MenuItem exitApp = new MenuItem("Exit"); file.getItems().addAll(openFile,exitApp); //Create SubMenu Edit. Menu edit = new Menu("Edit"); MenuItem properties = new MenuItem("Properties"); edit.getItems().add(properties); //Create SubMenu Help. Menu help = new Menu("Help"); MenuItem visitWebsite = new MenuItem("Visit Website"); help.getItems().add(visitWebsite); mainMenu.getMenus().addAll(file, edit, help); //Create some toolbar buttons Button openFileBtn = new Button(); Button printBtn = new Button(); Button snapshotBtn = new Button(); //Add some button graphics openFileBtn.setGraphic(new ImageView("/menuexample/image/open.gif")); printBtn.setGraphic(new ImageView("/menuexample/image/print.gif")); snapshotBtn.setGraphic(new ImageView("/menuexample/image/snapshot.gif")); toolBar.getItems().addAll(openFileBtn, printBtn, snapshotBtn); //Add the ToolBar and Main Meu to the VBox topContainer.getChildren().add(mainMenu); topContainer.getChildren().add(toolBar); //Apply the VBox to the Top Border root.setTop(topContainer); Scene scene = new Scene(root, 300, 250); //Setup the Stage. primaryStage.setTitle("MenuExample"); primaryStage.setScene(scene); primaryStage.show(); } /** * The main() method is ignored in correctly deployed JavaFX application. * main() serves only as fallback in case the application can not be * launched through deployment artifacts, e.g., in IDEs with limited FX * support. NetBeans ignores main(). * * @param args the command line arguments */ public static void main(String[] args) { launch(args); } }