我有一个奇怪的问题,虽然我对css和所有人都有很好的了解。但在javafx我面临着奇怪的情况。当我将光标从MenuItem移开时,背景颜色变为蓝色。
这是我的代码
<MenuButton id="scMenuButton" fx:id="searchCriteriaMenu" mnemonicParsing="false" nodeOrientation="LEFT_TO_RIGHT" text="Search Template" textFill="WHITE" wrapText="true">
<items>
<!-- <MenuItem id="scMenuItem" fx:id="scMenuItem" mnemonicParsing="false" style="-fx-background-color: transparent; -fx-padding: 0; -fx-margin: 0;">
<graphic> -->
<CustomMenuItem id="#searchCustomMenuItem" fx:id="scMenuItem" hideOnClick="false" mnemonicParsing="false" style="-fx-background-color: transparent; -fx-padding: 0; -fx-margin: 0;" styleClass="redBorder">
<content>
<VBox id="searchMbox" fx:id="advancedSearchVbox" prefHeight="406.0" prefWidth="359.0" style="-fx-font-weight: bold;" visible="false">
<children>
<AnchorPane id="searchAnchorPane" minHeight="0.0" minWidth="0.0" prefHeight="615.0" prefWidth="200.0" styleClass="noborder">
<children>
<HBox layoutY="76.0" minHeight="168.0" minWidth="345.0" prefHeight="168.0" prefWidth="357.0">
<children>
<ScrollPane hbarPolicy="NEVER" maxHeight="230.0" minWidth="355.0" prefHeight="216.0" prefWidth="355.0" vbarPolicy="AS_NEEDED">
<content>
<VBox fx:id="userSelectedValues" fillWidth="true" layoutY="5.0" maxWidth="355.0">
</VBox>
</content>
</ScrollPane>
</children>
</HBox>
<Group layoutY="-100.0">
<children>
<HBox layoutX="7.0" layoutY="350.0" prefHeight="35.0" prefWidth="348.0">
<children>
<Text layoutX="7.0" layoutY="335.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Template Name">
<HBox.margin>
<Insets right="5.0" top="9.0" />
</HBox.margin>
</Text>
<ComboBox fx:id="templateNameComboBox" layoutX="94.0" layoutY="330.0" prefWidth="248.0" promptText="Select Template Name">
<HBox.margin>
<Insets left="7.0" />
</HBox.margin>
</ComboBox>
</children>
</HBox>
<HBox layoutX="7.0" layoutY="385.0" prefHeight="35.0" prefWidth="348.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Type of template">
<HBox.margin>
<Insets top="9.0" />
</HBox.margin>
</Text>
<ComboBox fx:id="templateTypeComboBox" prefWidth="248.0" promptText="Select Template Type">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Private" />
<String fx:value="Public" />
</FXCollections>
</items>
<HBox.margin>
<Insets left="5.0" />
</HBox.margin>
</ComboBox>
</children>
</HBox>
<HBox alignment="TOP_CENTER" layoutX="-8.0" layoutY="422.0" prefHeight="100.0" prefWidth="360.0">
<children>
<CheckBox fx:id="defaultTemplate" mnemonicParsing="false" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Set as a default template">
<HBox.margin>
<Insets top="3.0" />
</HBox.margin>
</Text>
</children>
</HBox>
<HBox layoutX="5.0" layoutY="450.0" prefHeight="45.0" prefWidth="352.0">
<children>
<Button mnemonicParsing="false" onAction="#onSaveTemplate" prefHeight="45.0" prefWidth="67.0" styleClass="advancedRedButton" text="Save Template" textAlignment="CENTER" wrapText="true">
<cursor>
<Cursor fx:constant="HAND" />
</cursor></Button>
<Button mnemonicParsing="false" onAction="#onEditTemplate" prefHeight="45.0" prefWidth="67.0" styleClass="advancedRedButton" text="Edit Template" textAlignment="CENTER" wrapText="true">
<HBox.margin>
<Insets left="8.0" />
</HBox.margin>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
<Button mnemonicParsing="false" onAction="#onDeleteTemplate" prefHeight="45.0" prefWidth="67.0" styleClass="advancedRedButton" text="Delete Template" textAlignment="CENTER" wrapText="true">
<HBox.margin>
<Insets left="8.0" />
</HBox.margin>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
<Button mnemonicParsing="false" onAction="#onClearTemplate" prefHeight="45.0" prefWidth="55.0" styleClass="advancedRedButton" text="Clear" textAlignment="CENTER" wrapText="true">
<HBox.margin>
<Insets left="8.0" />
</HBox.margin>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
<Button mnemonicParsing="false" onAction="#advancedSearch" prefHeight="45.0" prefWidth="55.0" styleClass="advancedRedButton" text="Search">
<HBox.margin>
<Insets left="8.0" />
</HBox.margin>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
</children>
</HBox>
</children>
</Group>
<HBox layoutX="5.0" layoutY="5.0" prefHeight="73.0" prefWidth="348.0">
<children>
<GridPane fx:id="gridPane" hgap="3.0" layoutX="6.6" layoutY="60.6" prefHeight="43.0" prefWidth="348.0" vgap="1.0" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="-3.0" AnchorPane.rightAnchor="-10.0" AnchorPane.topAnchor="51.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="132.99999237060547" minWidth="10.0" prefWidth="126.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="102.0" minWidth="10.0" prefWidth="102.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="115.0" minWidth="10.0" prefWidth="86.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="76.0" minWidth="10.0" prefWidth="28.0" />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="140.0" minHeight="10.0" prefHeight="24.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="275.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Field" textAlignment="CENTER" wrappingWidth="35.9765625" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<styleClass>
<String fx:value="boldFont" />
<String fx:value="px16Font" />
</styleClass>
</Text>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Operator" GridPane.columnIndex="1" GridPane.halignment="CENTER">
<styleClass>
<String fx:value="boldFont" />
<String fx:value="px16Font" />
</styleClass>
</Text>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Value" GridPane.columnIndex="2" GridPane.halignment="CENTER">
<styleClass>
<String fx:value="boldFont" />
<String fx:value="px16Font" />
</styleClass>
</Text>
<ComboBox fx:id="fieldName" prefWidth="150.0" promptText="Select Field" GridPane.rowIndex="1">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="CLSMESSAGEID" />
<String fx:value="PAYMENTTYPE" />
<String fx:value="REQUESTTYPE" />
<String fx:value="VALUEDATE" />
</FXCollections>
</items>
</ComboBox>
<ComboBox fx:id="operator" prefWidth="150.0" promptText="Select Operator" GridPane.columnIndex="1" GridPane.rowIndex="1">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="IN" />
<String fx:value="NOT IN" />
<String fx:value="EQUALS" />
<String fx:value="NOT EQUALS" />
<String fx:value="LESS THAN" />
<String fx:value="LESS THAN EQUALS" />
<String fx:value="GREATER THAN" />
<String fx:value="GREATER THAN EQUALS" />
</FXCollections>
</items>
</ComboBox>
<TextField fx:id="fieldValue" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<Button fx:id="addImage" mnemonicParsing="false" onAction="#addOptions" prefHeight="20.0" prefWidth="20.0" styleClass="addImg" GridPane.columnIndex="3" GridPane.rowIndex="1">
<GridPane.margin>
<Insets left="5.0" />
</GridPane.margin>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</Button>
</children>
</GridPane>
</children>
</HBox>
</children>
</AnchorPane>
</children>
</VBox>
</content>
</CustomMenuItem>
<!-- </graphic>
</MenuItem> -->
</items>
<HBox.margin>
<Insets left="6.0" />
</HBox.margin>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
<styleClass>
<String fx:value="redButton" />
<String fx:value="whiteText" />
</styleClass>
</MenuButton>