7

In the JavaFX Scene Builder there is a text field to search in the library:

enter image description here

Is this a default control (if so I can't find it) or did they simply style a text field?
I tried looking in the source code of the Scene Builder as well, but could not find it.

Aerus
  • 4,332
  • 5
  • 43
  • 62

2 Answers2

0

There is no premade control to work this way, but you can create one using TextField events.

For example see next code: AutoComplete ComboBox in JavaFX

Community
  • 1
  • 1
Sergey Grinev
  • 34,078
  • 10
  • 128
  • 141
0

We can make our own toolbar like this

<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;
}
Labeeb
  • 37
  • 1
  • 8