我想在javafx中创建自定义列表视图.在这里,我需要在列表单元格中绑定多个组件,如下所示,例如一个标签,一个文本字段,一个HBox下的一个按钮和两个按钮,一个超链接,另一个HBox中的一个标签,这些HBox属于一个VBox,这个VBox属于单个列表单元格,它将重复并生成一个列表视图.
代码是
<ListView fx:id="ListView" layoutX="0" layoutY="30" prefWidth="600" prefHeight="300">
<HBox fx:id="listBox" alignment="CENTER_LEFT">
<padding><Insets top="5" bottom="5" left="5"></Insets> </padding>
<HBox alignment="CENTER_LEFT" prefWidth="170" minWidth="88">
<Label fx:id="surveyName" text="Field A" styleClass="Name"></Label>
</HBox>
<VBox styleClass="Description" prefWidth="155" minWidth="86">
<HBox>
<HBox styleClass="surveyDesIcon" prefWidth="20" prefHeight="16"></HBox>
<Label fx:id="surveyCode" text="PRW3456HJ"></Label>
</HBox>
<HBox>
<HBox styleClass="DateIcon" prefWidth="20" prefHeight="16"></HBox>
<Label fx:id="Date" text="PRW3456HJ"></Label>
</HBox>
</VBox>
<HBox fx:id="Status" prefWidth="160" minWidth="80">
<Label fx:id="StatusLabel" text="Checking Files.."/>
</HBox>
<HBox fx:id="StatusIcon1" prefWidth="50" prefHeight="50" alignment="CENTER">
<Label styleClass="StatusIcon1" prefWidth="24" prefHeight="24" alignment="CENTER"/>
</HBox>
<HBox fx:id="StatusIcon2" prefWidth="50" prefHeight="50" styleClass="StatusIconBox" alignment="CENTER">
<Hyperlink styleClass="StatusIcon2" prefWidth="24" maxHeight="24" alignment="CENTER"/> …Run Code Online (Sandbox Code Playgroud) 我的问题是假设我们有一些文字,如"与我们一起享受一天",并且其字体大小,字体粗细,行高与H2标签相同,但此文本不是标题或副标题文本.那么现在我的问题是本文应该使用什么?如果我们使用H2标签,那么我们只需要编写font-family,如果我们使用P标签,那么我们需要应用所有这些属性,如font-size,font-weight,line-height和font-family.
这种情况的标准做法是什么?