In Scene Builder I'm getting an warning every time I open a .fxml file. The warning says:

Duplicate usage of fx:id="x2"

I don't remember to have set an fx:id of x2 to any element, but this is not really a problem. The problem is that I have hundreds of elements in several different containers and it's very hard to find this two elements with this fx:id to fix this warning.

Is there a way I can find an element in Scene Builder by searching it by its fx:id?

EDIT

The element with duplicated id was an Insets, I'm not sure how it is created, but I'm sure that it's not visible neither in the Library area, nor in the Hierarchy area, nor in the main area of the Scene Builder. Their ids were duplicated somehow when I copied and pasted an HBox with an Label and a Button inside. The ids of the HBox, Label and Button weren't duplicated, just the Insets' id was.

The Insets looks like this in the source code:

<HBox.margin>
    <Insets left="130.0" fx:id="x2" />
</HBox.margin>

I just removed their id and the problem was gone! Antoniossss' answer helped me.

有帮助吗?

解决方案

Why don't you just simply edit your generated fxml file with text editor and search for x2 in it?

其他提示

try the below to get the element by id

scene.lookup("#yourid");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top