0

I have a little question about StackPanes. In my application I have a StackPane and in it there is a TabPane and a searching mask. I have painted it provisionally with Paint.

enter image description here

The black frame shows a TabPane and the yellow frame shows the other layer, which also contains a search field (HBox). The tabs of my TabPane hhave a TreeView in it. Now I would like that if the search did not find anything, the frame (whole orange field) gets a red border. Now if I put a red border around the HBox, then it is not the border of the orange HBox that is red but the layer border (so the red border is shown like the yellow line). Can anyone tell me how to get the red frame around my HBox?

Here is my code:

<StackPane fx:id="TabVBox">
        <TabPane fx:id="TabPane" tabDragPolicy="REORDER" VBox.vgrow="ALWAYS">
            <Tab text=" + " fx:id="myFirstTab" closable="false">

            </Tab>
        </TabPane>
        <HBox fx:id="searchBox" visible="false" alignment="BOTTOM_RIGHT" pickOnBounds="false" styleClass="searchFilterBox">
            <TextField fx:id="filter" promptText="Search..."></TextField>
            <Button fx:id="applyFilter" onAction="#applyFilter" styleClass="searchFilerCss">
                <graphic>
                    <FontAwesomeIcon glyphName="SEARCH" size="10.0" styleClass="searchGlyphCss"/>
                </graphic>
            </Button>
            <Button fx:id="removeFilter" onAction="#removeFilter" styleClass="removeFilterCss">
                <graphic>
                    <FontAwesomeIcon glyphName="TIMES" size="12.0" styleClass="remoeGlyphCss"/>
                </graphic>
            </Button>
        </HBox>
</StackPane>

EDIT: I thinkg I should put the HBox in another container so that, I can position the HBox right but Im not familiar with other container than VBox.

Gregor
  • 409
  • 1
  • 5
  • 12
  • 1
    Using `StackPane.alignment="BOTTOM_RIGHT"`, `maxWidth="-Infinity"`, and `maxHeight="-Infinity"` for your `HBox` may accomplish what you want. – Slaw May 07 '20 at 10:51
  • 1
    Slaw is right. To elaborate a bit: `StackPane` resizes its children to the size closest to its own size; since there are no upper bounds on the size of your `HBox`, it's grown to the size of the `StackPane`. To avoid this you need to set the max size to the value of the `Region.USE_PREF_SIZE` constant which happens to be `-1/0=-Infinity`. If you want to place the `HBox` at a distance from the `StackPane` bounds, add a `` element with the appropriate insets to the `` element. – fabian May 07 '20 at 15:45

0 Answers0