我正在使用 fontawesomefx-8.9 并且我已将其字体大小设置为 15px 使用
.glyph-icon {
-fx-font-size: 15px;
}
然后我创建了一些 FontAwesomeIconViews 并将它们嵌入到一些按钮(JavaFX)中。
我必须面对的问题是将鼠标悬停在按钮上时将 fontAwesome 图标更改为矩形。
FXML 文件如下(FXMLDocument,fxml)
<?xml version="1.0" encoding="UTF-8"?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" stylesheets="@styles.css" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.111" fx:controller="test_fontawesome.FXMLDocumentController">
<children>
<Button fx:id="button" contentDisplay="TOP" layoutX="44.0" layoutY="41.0" onAction="#handleButtonAction" text="Click Me!" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="40.0">
<graphic>
<FontAwesomeIconView fill="BLUE" glyphName="CUT" />
</graphic></Button>
<Label fx:id="label" layoutX="126" layoutY="120" minHeight="16" minWidth="69" />
<Button fx:id="button1" contentDisplay="TOP" layoutX="183.0" layoutY="41.0" onAction="#handleButtonAction" text="Click Me!" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="40.0">
<graphic>
<FontAwesomeIconView fill="BLUE" glyphName="PLUS" />
</graphic>
</Button>
</children>
</AnchorPane>
CSS 是下面的文件(styles.css)
.root {
-fx-font-size: 12px ;
}
只要在场景生成器上预览一下,问题就会出现!
如果您想要源代码,请从here https://drive.google.com/open?id=0B84k1fZRHSMdNTdwVTlDWm1XQmM.
我曾经遇到过同样的问题..我记得将以下行添加到我的 css 文件中解决了这个问题。
.glyph-icon{ -fx-font-family:"Material Design Icons"; }
看起来您正在使用 FontAwesome 图标,可以尝试使用适当的字体系列。
.glyph-icon{ -fx-font-family:"FontAwesome"; }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)