本文介绍了弹出按钮如下所示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 JavaFX 中创建特定的组件.onClick 事件后显示弹出窗口的按钮.
I want to create specific component in JavaFX. Button which show poupup after onClick event.
场景:
点击按钮
We click button
Popup Shows below button(如图所示)
Popup Shows below button (like on the picture)
推荐答案
回答完这个问题,我才发现原来是重复的JavaFX 2 自定义弹出窗格,在某些答案中包含更多上下文信息.
After answering this, I realized it was a duplicate of JavaFX 2 custom popup pane, which has a bit more context info in some of the answers.
使用 MenuButton 并在附加到 MenuButton 的 menuItem,为要在弹出窗口中显示的内容设置图形.
Use a MenuButton and in a menuItem attached to the MenuButton, set a graphic for the content you want to display in your popup.
final MenuItem wizPopup = new MenuItem();
wizPopup.setGraphic(wizBox);
final MenuButton popupButton = new MenuButton("frobozz");
popupButton.getItems().setAll(
wizPopup
);
这是一个完整的可执行示例.
这篇关于弹出按钮如下所示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!