- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一种方法,以便在按下 Quit
MenuItem
时退出
应用程序。
我有以下方法:
@FXML
public void doExit(ActionEvent event) {
Platform.exit();
System.exit(0);
}
我收到此错误:
javafx.fxml.LoadException: Error resolving onAction='doExit', either the event handler is not in the Namespace or there is an error in the script.
project/build/resources/main/Player.fxml:21
Player.fxml
的第 21 行是这样的:
<MenuItem mnemonicParsing="false" onAction="doExit" text="Quit" />
我尝试删除/添加 @FXML
表示法,该方法未定义为 static
所以它应该可以工作,并且我正确导入了 ActionEvent
最佳答案
Edit1:好的,我设法在场景生成器
中从脚本模式
切换到方法模式
,这解决了问题,但现在我是得到:
javafx.fxml.LoadException: No controller specified.
project/build/resources/main/Player.fxml:21
<MenuItem mnemonicParsing="false" onAction="#doExit" text="Quit" />
编辑2:我设法以编程方式创建 Controller ,因为我没有任何包声明,而且我不想创建一个。
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Player.fxml"));
fxmlLoader.setController(new Player());
Parent root = (Parent)fxmlLoader.load();
关于JavaFX 无法在 MenuItem 上使用 onAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33933003/
我想为 MenuItem 实现键盘快捷键。我使用了下面的代码: ` 但是当我按下 CTRL+N 时,InputGestureText 属性没有响应。我正在使用
例子: 菜单 1(可见 = 假) 菜单 2(可见 = 假) 菜单 3(可见 = 真) 当点击 Menu3 时,我希望显示 Menu1 和 Menu2。 @Override public void on
我的应用程序中有菜单。我需要检查用户选择了哪个菜单项并采取适当的措施。我这样做是为了, @Override public boolean onOptionsItemSelected(MenuI
我有以下 xaml: TestItemModel 类仅包含一个 IsSelected bool 属
我是 BlackBerry 的新手,我仍然为 BlackBerry OS 5 开发应用程序。 我知道 BlackBerry 中的 MenuItem 类用于在 Blackberry 中创建菜单项。我的
在页面加载时,JavaScript 使第一个缩略图处于事件状态,但我想根据它正在加载的页面将其更改为第二个、第三个甚至第四个缩略图。 JavaScript 适用于第一个缩略图处于事件状态: $('#m
如何获取已单击的任何给定菜单项的文本? 菜单是动态填充的,所以我似乎仅限于此: Menu.MenuItems.Add(new MenuItem("MenuName", new EventHandle
我有一个"file"MenuItem,我想显示最近打开的文件列表。 这是我现在拥有的 xaml:
我一直在使用 React/Next.js 来使用 Material-UI,但遇到了一个奇怪且持续存在的错误。我无法获取呈现常规垂直下拉菜单。我如何获得 s 垂直渲染? 我搜索了文档,但找不到任何内容。
下面的代码我有问题。当我将鼠标悬停在菜单项上时,departmentsHover 类不会影响菜单项。颜色和背景图像没有改变。 我必须做什么? P.S 我在环境中使用 MS visual Studio
我的 TableViewController 类中有这个奇怪的错误消息 class MenuTableViewController: UITableViewController { filepriva
我正在使用旧版 MainMenu control (with MenuItem s) control in an application, and would like to implement zo
我在 Button 上有一个 ContextMenu,显示时它会显示一个菜单项列表,这很好。如果我将鼠标移到菜单中的某个项目上,它会高亮显示,但当我将鼠标悬停在文本上方和周围时,我也会得到一个辅助高亮
我想向我的 ContextMenu 的某些 MenuItems 添加一个 Ellipse。 遗憾的是我无法让它工作[没有显示任何内容]。 Canvas canvas = new Canvas() {
我有一个基于 MVVM 的 WPF 上下文菜单,并希望将菜单项的可见性绑定(bind)到 IsEnabled其子菜单项的属性。问题是:根MenuItem始终可见,即使所有子菜单项都被禁用。但是在菜单项
我想知道我上面提出的问题的答案。我发现了很多关于这个问题的信息,但仅限于 Java Swing,而且 Action 处理是完全不同的。感谢您的回答,我很抱歉我的英语不好。 最佳答案 你可以做到 Eve
在shinydashboard中,可以创建menuItem(),它们是侧边栏中的选项卡。我希望能够使用标准 input$foo 语法轮询哪个选项卡处于事件状态。 但是,我没能做到。我尝试引用 menu
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 8 年前。 Improve this ques
我有一个菜单,我想点击菜单,但如果你们知道我的意思的话,我不想点击文本。MenuItem 有一个边框或类似的东西,但是当我点击它时它不会重定向到我想要的页面,除非我点击文本。 是否可以单击整个“按钮”
我正在编写一个备份工具。在我的工具之上,我有一个包含两个工具条菜单项的菜单条。我根据我的期望稍微改变了颜色。不关注菜单看起来很棒: 当我现在单击菜单项"file"打开上下文菜单时,颜色变为白色,我无法
我是一名优秀的程序员,十分优秀!