JavaFX 搜索文本字段

问题描述 投票:0回答:2

在 JavaFX 场景生成器中,有一个用于在库中搜索的文本字段:

enter image description here

这是默认控件(如果是的话我找不到它)还是他们只是设置文本字段的样式?
我也尝试查看场景生成器的源代码,但找不到它。

javafx-2 scenebuilder
2个回答
0
投票

没有预制控件可以以这种方式工作,但您可以使用 TextField 事件创建一个控件。

例如,请参阅下一个代码:JavaFX 中的 AutoComplete ComboBox


0
投票

我们可以制作自己的工具栏像这样

<ToolBar prefHeight="40.0" prefWidth="349.0" >
        <items>
            <Button fx:id="buttonCloseSearch" styleClass="buttonSearchClose">
                <graphic>
                    <FontAwesomeIconView styleClass="buttonSearchCloseIcon" />
                </graphic>
            </Button>
            <CustomTextField styleClass="searchField">
                <left>
                    <Label styleClass="searchBoxLabel">
                        <graphic>
                            <FontAwesomeIconView styleClass="searchBoxLabelIcon" />
                        </graphic>
                    </Label>
                </left>
            </CustomTextField>
            <Button fx:id="buttonUpSearch" styleClass="buttonUpSearch">
                <graphic>
                    <FontAwesomeIconView styleClass="buttonSearchUpIcon" />
                </graphic>
            </Button>
            <Button fx:id="buttonDownSearch" styleClass="buttonDownSearch">
                <graphic>
                    <FontAwesomeIconView styleClass="buttonSearchDownIcon" />
                </graphic>
            </Button>
        <Label text="1 of 2 matchs" />
        </items>
    </ToolBar>

.buttonSearchCloseIcon {
    -glyph-size: 15;
    -glyph-name: CLOSE;
}

.buttonSearchUpIcon {
    -glyph-size: 15;
    -glyph-name: CARET_UP;
}

.buttonSearchDownIcon {
    -glyph-size: 15;
    -glyph-name: CARET_DOWN;
}

.buttonSearchClose, .buttonUpSearch, .buttonDownSearch {
    -fx-background-color: transparent;
    -fx-background-insets: 0;
}

.searchBoxLabel {
    -fx-padding: 0 2 0 7;
}

.searchBoxLabelIcon {
    -glyph-size: 13;
    -glyph-name: SEARCH;
}

© www.soinside.com 2019 - 2024. All rights reserved.