Create MenuBar in JavaFX
________________________________________________
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.scene.layout.FlowPane; import javafx.stage.Stage; public class JavaFXMenuBar extends Application{ @Override public void start(Stage pStage) { FlowPane pane = new FlowPane(); MenuBar mBar = new MenuBar(); final Menu m1 = new Menu("File"); final Menu m2 = new Menu("Options"); final Menu m3 = new Menu("Help"); mBar.getMenus().addAll(m1, m2, m3); MenuItem item1 = new MenuItem("New File"); MenuItem item2 = new MenuItem("Open File"); MenuItem item3 = new MenuItem("Save File"); m1.getItems().addAll(item1, item2, item3); pane.getChildren().add(mBar); Scene scene = new Scene(pane, 250, 250); pStage.setTitle("JavaFX MenuBar"); pStage.setScene(scene); pStage.show(); } public static void main(String[] args) { Application.launch(args); } }
_____________________________________________
Dark Hers
YouTube
https://instagram.com/darkhers
https://www.facebook.com/darkhers
TikTok
https://www.tiktok.com/@darkhers
https://www.pinterest.co.uk/darkhers
Comments
Post a Comment