import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
//创建菜单栏
MenuBar menuBar = new MenuBar();
Text text = new Text("JavaFX");
BorderPane borderPane = new BorderPane();
borderPane.setTop(menuBar);
//创建菜单并设置字符F为热键(也就是说按下F键会自动展开文件对应的下拉菜单)
Menu fileM = new Menu(
JavaFX中创建菜单项
最新推荐文章于 2024-06-18 21:40:30 发布
本文介绍了如何在JavaFX中创建和使用MenuBar、Menu及MenuItem,展示了如何构建一个功能性的菜单项系统,最终实现的运行效果如下图所示。
摘要由CSDN通过智能技术生成