我正在搜索如何在css中设置MenuButton
上下文菜单的坐标,但没有找到实现的方法。我想将Conext菜单从实际位置降低,如附加的示例图像,如果可能,然后向上箭头。看看我的代码。
<MenuButton layoutX="1046.0" layoutY="38.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="30.0" styleClass="notification-button">
<graphic>
<Pane>
<children>
<Circle fill="#db5344" layoutX="20.0" radius="10.0" stroke="BLACK" strokeType="OUTSIDE" strokeWidth="2.0" />
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="12.3" layoutY="-8.5" prefHeight="10.0" prefWidth="15.0" text="0" textAlignment="CENTER" />
</children>
</Pane>
</graphic>
<items>
<MenuItem mnemonicParsing="false" text="Sample" />
</items>
</MenuButton>
.menu-button > .arrow-button {
-fx-padding: 0;
}
.menu-button > .arrow-button > .arrow {
-fx-padding: 0;
}
.menu-item {
-fx-padding: 10;
}
.menu-item .label {
-fx-text-fill: white;
}
.menu-item:focused {
-fx-background-color: darkgray;
}
.menu-item:focused .label {
-fx-text-fill: blue;
}
.menu-item .label {
-fx-text-fill: yellow;
}
.menu-item:focused .label {
-fx-text-fill: white;
}
.context-menu {
-fx-skin: "com.sun.javafx.scene.control.skin.ContextMenuSkin";
-fx-text-fill: white;
-fx-background-color: #006699;
-fx-background-insets: 0, 1, 2;
-fx-background-radius: 0 6 6 6, 0 5 5 5, 0 4 4 4;
-fx-padding: 10px;
}
.context-menu .separator {
-fx-padding: 10;
}
.context-menu .container {
-fx-padding: 10;
}
.context-menu .scroll-arrow {
-fx-padding: 10;
-fx-background-color: #006699;
}
.context-menu .scroll-arrow:hover {
-fx-background: -fx-accent;
-fx-background-color: #006699;
-fx-text-fill: -fx-selection-bar-text;
}
.context-menu:show-mnemonics .mnemonic-underline {
-fx-stroke: -fx-text-fill;
}
以下附加图片将帮助您理解我的问题。 第一个图像输出我当前的代码,第二个和第三个图像是我想要的。第二张和第三张图片都用于自定义样式,用于下载网页。我可以在JavaFX2中实现相同的目标吗?
正如您可以看到我的fxml代码,我在其中使用了MenuButton
和MenuItem
。如果你认为这不会有帮助。请告诉我其他方法。
答案 0 :(得分:0)
嗯,我相信有很多开发人员知道如何做到这一点。可能是他们没有时间或不知道我的问题。
顺便说一下,我浪费了差不多2天的时间。但很高兴我能够解决这个问题。