AnchorPane elements ignore Mouse click












0














I initialized some elements not my Anchor Pane:



AnchorPane root = new AnchorPane(listLoader.load(), textareaLoader.load(), fieldLoader.load(), menuLoader.load(), buttonLoader.load());


But when I try to click on the MenuBar or the List View it doesn't works. For example, in this case I can click on the buttons (maybe) because it is the last element that I initialize in the AnchorPane constructor. I cannot use a BorderPane or any other Layout, so I need to find a solution with this configuration.
These are my fxml files:

list.fxml



<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.ListController">
<children>
<AnchorPane>
<children>
<ListView fx:id="listView" layoutX="1.0" layoutY="31.0" prefHeight="371.0" prefWidth="239.0" />
</children>
</AnchorPane>
</children>




menuBar.fxml



<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="mailbox.MenuBarController">
<children>
<AnchorPane>
<children>
<MenuBar fx:id="menuBar" layoutX="0.0" layoutY="0.0">
<menus>
<Menu text="File">
<items>
<MenuItem onAction="#elimina" text="Elimina" />
</items>
</Menu>
<Menu text="Cambia Account">
<items>
<MenuItem fx:id="email1" text="filippo@hotmail.it" />
<MenuItem fx:id="email2" text="giancarlo@yahoo.it" />
<MenuItem fx:id="email3" text="alessandro@gmail.it" />
</items>
</Menu>
</menus>
</MenuBar>
</children>
</AnchorPane>
</children>




textArea.fxml



<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="mailbox.TextAreaController">
<children>
<AnchorPane>
<children>
<TextArea fx:id="textarea" editable="false" layoutX="246.0" layoutY="255.0" prefHeight="144.0" prefWidth="350.0" />
</children>
</AnchorPane>
</children>




button.fxml



<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.ButtonController">
<children>
<AnchorPane>
<children>
<Button id="scrivi" layoutX="268.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="65.0" text="Scrivi" />
<Button id="reply" layoutX="342.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="65.0" text="Reply" />
<Button id="replyall" layoutX="420.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="75.0" text="Reply-All" />
<Button id="forward" layoutX="511.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="75.0" text="Forward" />
</children>
</AnchorPane>
</children>




textfield.fxml



<AnchorPane mouseTransparent="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextFieldController">
<children>
<AnchorPane>
<children>
<TextField fx:id="id" editable="false" layoutX="355.0" layoutY="39.0" mouseTransparent="false" prefHeight="27.0" prefWidth="35.0" />
<TextField fx:id="mitt" editable="false" layoutX="355.0" layoutY="72.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="dest" editable="false" layoutX="355.0" layoutY="108.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="oggetto" editable="false" layoutX="355.0" layoutY="144.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="data" editable="false" layoutX="437.0" layoutY="39.0" mouseTransparent="false" prefHeight="27.0" prefWidth="100.0" />
<Label layoutX="329.0" layoutY="44.0" text="ID:" />
<Label layoutX="291.0" layoutY="77.0" text="Mittente:" />
<Label layoutX="398.0" layoutY="44.0" text="Data:" />
<Label layoutX="268.0" layoutY="113.0" text="Destinatario:" />
<Label layoutX="292.0" layoutY="149.0" text="Oggetto:" />
</children>
</AnchorPane>
</children>




I made them with Scene Builder, I need to keep them separately because I prefer a singular file for each controller.
EDIT:
Output



EDIT2:
This is the first AnchorPane (on the right you can see the settings):
SB1
This is the second AnchorPane
SB2
This is the Textarea:
enter image description here










share|improve this question
























  • Why can't you use BorderPane or any other layout ?
    – Pagbo
    Nov 20 at 11:28










  • Because I should re-design all the application and modify all the fxml files. With the AnchorPane, as you can see, I already positioned all the elements where I need them to be
    – Samoa Joe
    Nov 20 at 11:33










  • Try adding an mouse event filter to the window to see what the actual EventTarget is. If it isn't the ListView or one of its children then you likely have some node overlapping it.
    – Slaw
    Nov 20 at 11:52












  • @Slaw With "overlapping" you mean that there is one element on another one? Because I tried to add them singularly and if I set the first two elements it works, but as soon as I set the text area and the textfield I cannot click anymore on the first two elements. I'm gonna edit the question to show you the output of the application.
    – Samoa Joe
    Nov 20 at 11:59










  • Some node may still be overlapping the other nodes, even if you can't see it. Add the code used to load the FXML files so we can run/debug your application on our own machines (i.e. include a Minimal, Complete, and Verifiable example).
    – Slaw
    Nov 20 at 12:31


















0














I initialized some elements not my Anchor Pane:



AnchorPane root = new AnchorPane(listLoader.load(), textareaLoader.load(), fieldLoader.load(), menuLoader.load(), buttonLoader.load());


But when I try to click on the MenuBar or the List View it doesn't works. For example, in this case I can click on the buttons (maybe) because it is the last element that I initialize in the AnchorPane constructor. I cannot use a BorderPane or any other Layout, so I need to find a solution with this configuration.
These are my fxml files:

list.fxml



<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.ListController">
<children>
<AnchorPane>
<children>
<ListView fx:id="listView" layoutX="1.0" layoutY="31.0" prefHeight="371.0" prefWidth="239.0" />
</children>
</AnchorPane>
</children>




menuBar.fxml



<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="mailbox.MenuBarController">
<children>
<AnchorPane>
<children>
<MenuBar fx:id="menuBar" layoutX="0.0" layoutY="0.0">
<menus>
<Menu text="File">
<items>
<MenuItem onAction="#elimina" text="Elimina" />
</items>
</Menu>
<Menu text="Cambia Account">
<items>
<MenuItem fx:id="email1" text="filippo@hotmail.it" />
<MenuItem fx:id="email2" text="giancarlo@yahoo.it" />
<MenuItem fx:id="email3" text="alessandro@gmail.it" />
</items>
</Menu>
</menus>
</MenuBar>
</children>
</AnchorPane>
</children>




textArea.fxml



<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="mailbox.TextAreaController">
<children>
<AnchorPane>
<children>
<TextArea fx:id="textarea" editable="false" layoutX="246.0" layoutY="255.0" prefHeight="144.0" prefWidth="350.0" />
</children>
</AnchorPane>
</children>




button.fxml



<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.ButtonController">
<children>
<AnchorPane>
<children>
<Button id="scrivi" layoutX="268.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="65.0" text="Scrivi" />
<Button id="reply" layoutX="342.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="65.0" text="Reply" />
<Button id="replyall" layoutX="420.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="75.0" text="Reply-All" />
<Button id="forward" layoutX="511.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="75.0" text="Forward" />
</children>
</AnchorPane>
</children>




textfield.fxml



<AnchorPane mouseTransparent="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextFieldController">
<children>
<AnchorPane>
<children>
<TextField fx:id="id" editable="false" layoutX="355.0" layoutY="39.0" mouseTransparent="false" prefHeight="27.0" prefWidth="35.0" />
<TextField fx:id="mitt" editable="false" layoutX="355.0" layoutY="72.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="dest" editable="false" layoutX="355.0" layoutY="108.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="oggetto" editable="false" layoutX="355.0" layoutY="144.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="data" editable="false" layoutX="437.0" layoutY="39.0" mouseTransparent="false" prefHeight="27.0" prefWidth="100.0" />
<Label layoutX="329.0" layoutY="44.0" text="ID:" />
<Label layoutX="291.0" layoutY="77.0" text="Mittente:" />
<Label layoutX="398.0" layoutY="44.0" text="Data:" />
<Label layoutX="268.0" layoutY="113.0" text="Destinatario:" />
<Label layoutX="292.0" layoutY="149.0" text="Oggetto:" />
</children>
</AnchorPane>
</children>




I made them with Scene Builder, I need to keep them separately because I prefer a singular file for each controller.
EDIT:
Output



EDIT2:
This is the first AnchorPane (on the right you can see the settings):
SB1
This is the second AnchorPane
SB2
This is the Textarea:
enter image description here










share|improve this question
























  • Why can't you use BorderPane or any other layout ?
    – Pagbo
    Nov 20 at 11:28










  • Because I should re-design all the application and modify all the fxml files. With the AnchorPane, as you can see, I already positioned all the elements where I need them to be
    – Samoa Joe
    Nov 20 at 11:33










  • Try adding an mouse event filter to the window to see what the actual EventTarget is. If it isn't the ListView or one of its children then you likely have some node overlapping it.
    – Slaw
    Nov 20 at 11:52












  • @Slaw With "overlapping" you mean that there is one element on another one? Because I tried to add them singularly and if I set the first two elements it works, but as soon as I set the text area and the textfield I cannot click anymore on the first two elements. I'm gonna edit the question to show you the output of the application.
    – Samoa Joe
    Nov 20 at 11:59










  • Some node may still be overlapping the other nodes, even if you can't see it. Add the code used to load the FXML files so we can run/debug your application on our own machines (i.e. include a Minimal, Complete, and Verifiable example).
    – Slaw
    Nov 20 at 12:31
















0












0








0







I initialized some elements not my Anchor Pane:



AnchorPane root = new AnchorPane(listLoader.load(), textareaLoader.load(), fieldLoader.load(), menuLoader.load(), buttonLoader.load());


But when I try to click on the MenuBar or the List View it doesn't works. For example, in this case I can click on the buttons (maybe) because it is the last element that I initialize in the AnchorPane constructor. I cannot use a BorderPane or any other Layout, so I need to find a solution with this configuration.
These are my fxml files:

list.fxml



<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.ListController">
<children>
<AnchorPane>
<children>
<ListView fx:id="listView" layoutX="1.0" layoutY="31.0" prefHeight="371.0" prefWidth="239.0" />
</children>
</AnchorPane>
</children>




menuBar.fxml



<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="mailbox.MenuBarController">
<children>
<AnchorPane>
<children>
<MenuBar fx:id="menuBar" layoutX="0.0" layoutY="0.0">
<menus>
<Menu text="File">
<items>
<MenuItem onAction="#elimina" text="Elimina" />
</items>
</Menu>
<Menu text="Cambia Account">
<items>
<MenuItem fx:id="email1" text="filippo@hotmail.it" />
<MenuItem fx:id="email2" text="giancarlo@yahoo.it" />
<MenuItem fx:id="email3" text="alessandro@gmail.it" />
</items>
</Menu>
</menus>
</MenuBar>
</children>
</AnchorPane>
</children>




textArea.fxml



<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="mailbox.TextAreaController">
<children>
<AnchorPane>
<children>
<TextArea fx:id="textarea" editable="false" layoutX="246.0" layoutY="255.0" prefHeight="144.0" prefWidth="350.0" />
</children>
</AnchorPane>
</children>




button.fxml



<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.ButtonController">
<children>
<AnchorPane>
<children>
<Button id="scrivi" layoutX="268.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="65.0" text="Scrivi" />
<Button id="reply" layoutX="342.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="65.0" text="Reply" />
<Button id="replyall" layoutX="420.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="75.0" text="Reply-All" />
<Button id="forward" layoutX="511.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="75.0" text="Forward" />
</children>
</AnchorPane>
</children>




textfield.fxml



<AnchorPane mouseTransparent="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextFieldController">
<children>
<AnchorPane>
<children>
<TextField fx:id="id" editable="false" layoutX="355.0" layoutY="39.0" mouseTransparent="false" prefHeight="27.0" prefWidth="35.0" />
<TextField fx:id="mitt" editable="false" layoutX="355.0" layoutY="72.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="dest" editable="false" layoutX="355.0" layoutY="108.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="oggetto" editable="false" layoutX="355.0" layoutY="144.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="data" editable="false" layoutX="437.0" layoutY="39.0" mouseTransparent="false" prefHeight="27.0" prefWidth="100.0" />
<Label layoutX="329.0" layoutY="44.0" text="ID:" />
<Label layoutX="291.0" layoutY="77.0" text="Mittente:" />
<Label layoutX="398.0" layoutY="44.0" text="Data:" />
<Label layoutX="268.0" layoutY="113.0" text="Destinatario:" />
<Label layoutX="292.0" layoutY="149.0" text="Oggetto:" />
</children>
</AnchorPane>
</children>




I made them with Scene Builder, I need to keep them separately because I prefer a singular file for each controller.
EDIT:
Output



EDIT2:
This is the first AnchorPane (on the right you can see the settings):
SB1
This is the second AnchorPane
SB2
This is the Textarea:
enter image description here










share|improve this question















I initialized some elements not my Anchor Pane:



AnchorPane root = new AnchorPane(listLoader.load(), textareaLoader.load(), fieldLoader.load(), menuLoader.load(), buttonLoader.load());


But when I try to click on the MenuBar or the List View it doesn't works. For example, in this case I can click on the buttons (maybe) because it is the last element that I initialize in the AnchorPane constructor. I cannot use a BorderPane or any other Layout, so I need to find a solution with this configuration.
These are my fxml files:

list.fxml



<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.ListController">
<children>
<AnchorPane>
<children>
<ListView fx:id="listView" layoutX="1.0" layoutY="31.0" prefHeight="371.0" prefWidth="239.0" />
</children>
</AnchorPane>
</children>




menuBar.fxml



<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="mailbox.MenuBarController">
<children>
<AnchorPane>
<children>
<MenuBar fx:id="menuBar" layoutX="0.0" layoutY="0.0">
<menus>
<Menu text="File">
<items>
<MenuItem onAction="#elimina" text="Elimina" />
</items>
</Menu>
<Menu text="Cambia Account">
<items>
<MenuItem fx:id="email1" text="filippo@hotmail.it" />
<MenuItem fx:id="email2" text="giancarlo@yahoo.it" />
<MenuItem fx:id="email3" text="alessandro@gmail.it" />
</items>
</Menu>
</menus>
</MenuBar>
</children>
</AnchorPane>
</children>




textArea.fxml



<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="mailbox.TextAreaController">
<children>
<AnchorPane>
<children>
<TextArea fx:id="textarea" editable="false" layoutX="246.0" layoutY="255.0" prefHeight="144.0" prefWidth="350.0" />
</children>
</AnchorPane>
</children>




button.fxml



<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.ButtonController">
<children>
<AnchorPane>
<children>
<Button id="scrivi" layoutX="268.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="65.0" text="Scrivi" />
<Button id="reply" layoutX="342.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="65.0" text="Reply" />
<Button id="replyall" layoutX="420.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="75.0" text="Reply-All" />
<Button id="forward" layoutX="511.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="75.0" text="Forward" />
</children>
</AnchorPane>
</children>




textfield.fxml



<AnchorPane mouseTransparent="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextFieldController">
<children>
<AnchorPane>
<children>
<TextField fx:id="id" editable="false" layoutX="355.0" layoutY="39.0" mouseTransparent="false" prefHeight="27.0" prefWidth="35.0" />
<TextField fx:id="mitt" editable="false" layoutX="355.0" layoutY="72.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="dest" editable="false" layoutX="355.0" layoutY="108.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="oggetto" editable="false" layoutX="355.0" layoutY="144.0" mouseTransparent="false" prefHeight="27.0" prefWidth="182.0" />
<TextField fx:id="data" editable="false" layoutX="437.0" layoutY="39.0" mouseTransparent="false" prefHeight="27.0" prefWidth="100.0" />
<Label layoutX="329.0" layoutY="44.0" text="ID:" />
<Label layoutX="291.0" layoutY="77.0" text="Mittente:" />
<Label layoutX="398.0" layoutY="44.0" text="Data:" />
<Label layoutX="268.0" layoutY="113.0" text="Destinatario:" />
<Label layoutX="292.0" layoutY="149.0" text="Oggetto:" />
</children>
</AnchorPane>
</children>




I made them with Scene Builder, I need to keep them separately because I prefer a singular file for each controller.
EDIT:
Output



EDIT2:
This is the first AnchorPane (on the right you can see the settings):
SB1
This is the second AnchorPane
SB2
This is the Textarea:
enter image description here







java javafx fxml






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 17:00

























asked Nov 20 at 11:26









Samoa Joe

206




206












  • Why can't you use BorderPane or any other layout ?
    – Pagbo
    Nov 20 at 11:28










  • Because I should re-design all the application and modify all the fxml files. With the AnchorPane, as you can see, I already positioned all the elements where I need them to be
    – Samoa Joe
    Nov 20 at 11:33










  • Try adding an mouse event filter to the window to see what the actual EventTarget is. If it isn't the ListView or one of its children then you likely have some node overlapping it.
    – Slaw
    Nov 20 at 11:52












  • @Slaw With "overlapping" you mean that there is one element on another one? Because I tried to add them singularly and if I set the first two elements it works, but as soon as I set the text area and the textfield I cannot click anymore on the first two elements. I'm gonna edit the question to show you the output of the application.
    – Samoa Joe
    Nov 20 at 11:59










  • Some node may still be overlapping the other nodes, even if you can't see it. Add the code used to load the FXML files so we can run/debug your application on our own machines (i.e. include a Minimal, Complete, and Verifiable example).
    – Slaw
    Nov 20 at 12:31




















  • Why can't you use BorderPane or any other layout ?
    – Pagbo
    Nov 20 at 11:28










  • Because I should re-design all the application and modify all the fxml files. With the AnchorPane, as you can see, I already positioned all the elements where I need them to be
    – Samoa Joe
    Nov 20 at 11:33










  • Try adding an mouse event filter to the window to see what the actual EventTarget is. If it isn't the ListView or one of its children then you likely have some node overlapping it.
    – Slaw
    Nov 20 at 11:52












  • @Slaw With "overlapping" you mean that there is one element on another one? Because I tried to add them singularly and if I set the first two elements it works, but as soon as I set the text area and the textfield I cannot click anymore on the first two elements. I'm gonna edit the question to show you the output of the application.
    – Samoa Joe
    Nov 20 at 11:59










  • Some node may still be overlapping the other nodes, even if you can't see it. Add the code used to load the FXML files so we can run/debug your application on our own machines (i.e. include a Minimal, Complete, and Verifiable example).
    – Slaw
    Nov 20 at 12:31


















Why can't you use BorderPane or any other layout ?
– Pagbo
Nov 20 at 11:28




Why can't you use BorderPane or any other layout ?
– Pagbo
Nov 20 at 11:28












Because I should re-design all the application and modify all the fxml files. With the AnchorPane, as you can see, I already positioned all the elements where I need them to be
– Samoa Joe
Nov 20 at 11:33




Because I should re-design all the application and modify all the fxml files. With the AnchorPane, as you can see, I already positioned all the elements where I need them to be
– Samoa Joe
Nov 20 at 11:33












Try adding an mouse event filter to the window to see what the actual EventTarget is. If it isn't the ListView or one of its children then you likely have some node overlapping it.
– Slaw
Nov 20 at 11:52






Try adding an mouse event filter to the window to see what the actual EventTarget is. If it isn't the ListView or one of its children then you likely have some node overlapping it.
– Slaw
Nov 20 at 11:52














@Slaw With "overlapping" you mean that there is one element on another one? Because I tried to add them singularly and if I set the first two elements it works, but as soon as I set the text area and the textfield I cannot click anymore on the first two elements. I'm gonna edit the question to show you the output of the application.
– Samoa Joe
Nov 20 at 11:59




@Slaw With "overlapping" you mean that there is one element on another one? Because I tried to add them singularly and if I set the first two elements it works, but as soon as I set the text area and the textfield I cannot click anymore on the first two elements. I'm gonna edit the question to show you the output of the application.
– Samoa Joe
Nov 20 at 11:59












Some node may still be overlapping the other nodes, even if you can't see it. Add the code used to load the FXML files so we can run/debug your application on our own machines (i.e. include a Minimal, Complete, and Verifiable example).
– Slaw
Nov 20 at 12:31






Some node may still be overlapping the other nodes, even if you can't see it. Add the code used to load the FXML files so we can run/debug your application on our own machines (i.e. include a Minimal, Complete, and Verifiable example).
– Slaw
Nov 20 at 12:31














1 Answer
1






active

oldest

votes


















5














AnchorPane is one of the worst layouts, if you're designing a responsive layout, since it does not allow you to take the size of other children into account, when positioning a child (except if you use listeners/bindings to update layout parameters).



Your problem in this specific case is that your button.fxml covers all the content of the other fxmls and therefore receives all the MouseEvents. To visualize the area the fxml covers, just add this attribute to the root of button.fxml: style="-fx-background-color: rgba(0, 0, 255, 0.5)".



A possible workaround would be making the child fxmls as small as possible and specifying the root position in the parent:



Identify the minimum layoutX and layoutY of the children of the inner <AnchorPane>, set those values for the root (or add them to previous values of the root) and subtract these values from all children of the the inner <AnchorPane>.



<!-- specify min layoutX/Y as position for root -->
<AnchorPane xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1"
layoutX="268"
layoutY="200"
fx:controller="mailbox.ButtonController">
<children>
<AnchorPane>
<children>
<!-- subtract root layoutX/Y from positions -->
<Button id="scrivi" mnemonicParsing="false" prefHeight="27.0"
prefWidth="65.0" text="Scrivi" />
<Button id="reply" layoutX="74" mnemonicParsing="false"
prefHeight="27.0" prefWidth="65.0" text="Reply" />
<Button id="replyall" layoutX="152" mnemonicParsing="false"
prefHeight="27.0" prefWidth="75.0" text="Reply-All" />
<Button id="forward" layoutX="243" mnemonicParsing="false"
prefHeight="27.0" prefWidth="75.0" text="Forward" />
</children>
</AnchorPane>
</children>
</AnchorPane>


(Proceed accordingly with the other fxmls.)



It is still a terrible idea overlay nodes this way, since you're using absolute positions and any modification of one of the fxmls could require you to update multiple others to avoid overlays. Even worse looks different depending on the OS/settings. For one OS the scene could look fine, on another one one your nodes could overlap.

For this reason I recommend avoiding using absolute positioning, unless you're 100% sure the node sizes are known. A scene like the one shown is better created using BorderPane/HBox/VBox and/or GridPane...






share|improve this answer























  • Thank you very much! Now the only thing I cannot select is the list view, if I understood your code correctly, you've set the dimension of the AnchorPane by looking at where the first button is? So for the list view I should select a layoutX="1.0"and a layoutY="31.0"?
    – Samoa Joe
    Nov 20 at 13:30










  • @SamoaJoe button.fxml is just the topmost child. You need to make sure no child after the one containing the ListView covers the ListView. This is done by identifying the leftmost coordinate (minimum layoutX) and topmost coordinate (minimum layoutY), setting these values for the fxml root and subtracting them from the properties of all elements contained in the pane.
    – fabian
    Nov 20 at 15:27










  • And should I consider the prefHeight and the prefWidth of the elements? Or just the layouts?
    – Samoa Joe
    Nov 20 at 15:39










  • We're trying to find the appropriate top left coordinate of the container, so no, width and height are irrelevant.
    – fabian
    Nov 20 at 16:04










  • I found the problem, which is the textArea. I tried to edit it like this <AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextAreaController"> <children> <AnchorPane> <children> <TextArea id="textarea" layoutX="255.0" layoutY="255.0" prefHeight="144.0" prefWidth="330.0" /> </children> </AnchorPane> </children> </AnchorPane> <br> In Scene Builder it shows that the AnchorPane is way bigger that the textarea. I'm gonna edit the question to show you the problem
    – Samoa Joe
    Nov 20 at 16:54













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391994%2fanchorpane-elements-ignore-mouse-click%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














AnchorPane is one of the worst layouts, if you're designing a responsive layout, since it does not allow you to take the size of other children into account, when positioning a child (except if you use listeners/bindings to update layout parameters).



Your problem in this specific case is that your button.fxml covers all the content of the other fxmls and therefore receives all the MouseEvents. To visualize the area the fxml covers, just add this attribute to the root of button.fxml: style="-fx-background-color: rgba(0, 0, 255, 0.5)".



A possible workaround would be making the child fxmls as small as possible and specifying the root position in the parent:



Identify the minimum layoutX and layoutY of the children of the inner <AnchorPane>, set those values for the root (or add them to previous values of the root) and subtract these values from all children of the the inner <AnchorPane>.



<!-- specify min layoutX/Y as position for root -->
<AnchorPane xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1"
layoutX="268"
layoutY="200"
fx:controller="mailbox.ButtonController">
<children>
<AnchorPane>
<children>
<!-- subtract root layoutX/Y from positions -->
<Button id="scrivi" mnemonicParsing="false" prefHeight="27.0"
prefWidth="65.0" text="Scrivi" />
<Button id="reply" layoutX="74" mnemonicParsing="false"
prefHeight="27.0" prefWidth="65.0" text="Reply" />
<Button id="replyall" layoutX="152" mnemonicParsing="false"
prefHeight="27.0" prefWidth="75.0" text="Reply-All" />
<Button id="forward" layoutX="243" mnemonicParsing="false"
prefHeight="27.0" prefWidth="75.0" text="Forward" />
</children>
</AnchorPane>
</children>
</AnchorPane>


(Proceed accordingly with the other fxmls.)



It is still a terrible idea overlay nodes this way, since you're using absolute positions and any modification of one of the fxmls could require you to update multiple others to avoid overlays. Even worse looks different depending on the OS/settings. For one OS the scene could look fine, on another one one your nodes could overlap.

For this reason I recommend avoiding using absolute positioning, unless you're 100% sure the node sizes are known. A scene like the one shown is better created using BorderPane/HBox/VBox and/or GridPane...






share|improve this answer























  • Thank you very much! Now the only thing I cannot select is the list view, if I understood your code correctly, you've set the dimension of the AnchorPane by looking at where the first button is? So for the list view I should select a layoutX="1.0"and a layoutY="31.0"?
    – Samoa Joe
    Nov 20 at 13:30










  • @SamoaJoe button.fxml is just the topmost child. You need to make sure no child after the one containing the ListView covers the ListView. This is done by identifying the leftmost coordinate (minimum layoutX) and topmost coordinate (minimum layoutY), setting these values for the fxml root and subtracting them from the properties of all elements contained in the pane.
    – fabian
    Nov 20 at 15:27










  • And should I consider the prefHeight and the prefWidth of the elements? Or just the layouts?
    – Samoa Joe
    Nov 20 at 15:39










  • We're trying to find the appropriate top left coordinate of the container, so no, width and height are irrelevant.
    – fabian
    Nov 20 at 16:04










  • I found the problem, which is the textArea. I tried to edit it like this <AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextAreaController"> <children> <AnchorPane> <children> <TextArea id="textarea" layoutX="255.0" layoutY="255.0" prefHeight="144.0" prefWidth="330.0" /> </children> </AnchorPane> </children> </AnchorPane> <br> In Scene Builder it shows that the AnchorPane is way bigger that the textarea. I'm gonna edit the question to show you the problem
    – Samoa Joe
    Nov 20 at 16:54


















5














AnchorPane is one of the worst layouts, if you're designing a responsive layout, since it does not allow you to take the size of other children into account, when positioning a child (except if you use listeners/bindings to update layout parameters).



Your problem in this specific case is that your button.fxml covers all the content of the other fxmls and therefore receives all the MouseEvents. To visualize the area the fxml covers, just add this attribute to the root of button.fxml: style="-fx-background-color: rgba(0, 0, 255, 0.5)".



A possible workaround would be making the child fxmls as small as possible and specifying the root position in the parent:



Identify the minimum layoutX and layoutY of the children of the inner <AnchorPane>, set those values for the root (or add them to previous values of the root) and subtract these values from all children of the the inner <AnchorPane>.



<!-- specify min layoutX/Y as position for root -->
<AnchorPane xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1"
layoutX="268"
layoutY="200"
fx:controller="mailbox.ButtonController">
<children>
<AnchorPane>
<children>
<!-- subtract root layoutX/Y from positions -->
<Button id="scrivi" mnemonicParsing="false" prefHeight="27.0"
prefWidth="65.0" text="Scrivi" />
<Button id="reply" layoutX="74" mnemonicParsing="false"
prefHeight="27.0" prefWidth="65.0" text="Reply" />
<Button id="replyall" layoutX="152" mnemonicParsing="false"
prefHeight="27.0" prefWidth="75.0" text="Reply-All" />
<Button id="forward" layoutX="243" mnemonicParsing="false"
prefHeight="27.0" prefWidth="75.0" text="Forward" />
</children>
</AnchorPane>
</children>
</AnchorPane>


(Proceed accordingly with the other fxmls.)



It is still a terrible idea overlay nodes this way, since you're using absolute positions and any modification of one of the fxmls could require you to update multiple others to avoid overlays. Even worse looks different depending on the OS/settings. For one OS the scene could look fine, on another one one your nodes could overlap.

For this reason I recommend avoiding using absolute positioning, unless you're 100% sure the node sizes are known. A scene like the one shown is better created using BorderPane/HBox/VBox and/or GridPane...






share|improve this answer























  • Thank you very much! Now the only thing I cannot select is the list view, if I understood your code correctly, you've set the dimension of the AnchorPane by looking at where the first button is? So for the list view I should select a layoutX="1.0"and a layoutY="31.0"?
    – Samoa Joe
    Nov 20 at 13:30










  • @SamoaJoe button.fxml is just the topmost child. You need to make sure no child after the one containing the ListView covers the ListView. This is done by identifying the leftmost coordinate (minimum layoutX) and topmost coordinate (minimum layoutY), setting these values for the fxml root and subtracting them from the properties of all elements contained in the pane.
    – fabian
    Nov 20 at 15:27










  • And should I consider the prefHeight and the prefWidth of the elements? Or just the layouts?
    – Samoa Joe
    Nov 20 at 15:39










  • We're trying to find the appropriate top left coordinate of the container, so no, width and height are irrelevant.
    – fabian
    Nov 20 at 16:04










  • I found the problem, which is the textArea. I tried to edit it like this <AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextAreaController"> <children> <AnchorPane> <children> <TextArea id="textarea" layoutX="255.0" layoutY="255.0" prefHeight="144.0" prefWidth="330.0" /> </children> </AnchorPane> </children> </AnchorPane> <br> In Scene Builder it shows that the AnchorPane is way bigger that the textarea. I'm gonna edit the question to show you the problem
    – Samoa Joe
    Nov 20 at 16:54
















5












5








5






AnchorPane is one of the worst layouts, if you're designing a responsive layout, since it does not allow you to take the size of other children into account, when positioning a child (except if you use listeners/bindings to update layout parameters).



Your problem in this specific case is that your button.fxml covers all the content of the other fxmls and therefore receives all the MouseEvents. To visualize the area the fxml covers, just add this attribute to the root of button.fxml: style="-fx-background-color: rgba(0, 0, 255, 0.5)".



A possible workaround would be making the child fxmls as small as possible and specifying the root position in the parent:



Identify the minimum layoutX and layoutY of the children of the inner <AnchorPane>, set those values for the root (or add them to previous values of the root) and subtract these values from all children of the the inner <AnchorPane>.



<!-- specify min layoutX/Y as position for root -->
<AnchorPane xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1"
layoutX="268"
layoutY="200"
fx:controller="mailbox.ButtonController">
<children>
<AnchorPane>
<children>
<!-- subtract root layoutX/Y from positions -->
<Button id="scrivi" mnemonicParsing="false" prefHeight="27.0"
prefWidth="65.0" text="Scrivi" />
<Button id="reply" layoutX="74" mnemonicParsing="false"
prefHeight="27.0" prefWidth="65.0" text="Reply" />
<Button id="replyall" layoutX="152" mnemonicParsing="false"
prefHeight="27.0" prefWidth="75.0" text="Reply-All" />
<Button id="forward" layoutX="243" mnemonicParsing="false"
prefHeight="27.0" prefWidth="75.0" text="Forward" />
</children>
</AnchorPane>
</children>
</AnchorPane>


(Proceed accordingly with the other fxmls.)



It is still a terrible idea overlay nodes this way, since you're using absolute positions and any modification of one of the fxmls could require you to update multiple others to avoid overlays. Even worse looks different depending on the OS/settings. For one OS the scene could look fine, on another one one your nodes could overlap.

For this reason I recommend avoiding using absolute positioning, unless you're 100% sure the node sizes are known. A scene like the one shown is better created using BorderPane/HBox/VBox and/or GridPane...






share|improve this answer














AnchorPane is one of the worst layouts, if you're designing a responsive layout, since it does not allow you to take the size of other children into account, when positioning a child (except if you use listeners/bindings to update layout parameters).



Your problem in this specific case is that your button.fxml covers all the content of the other fxmls and therefore receives all the MouseEvents. To visualize the area the fxml covers, just add this attribute to the root of button.fxml: style="-fx-background-color: rgba(0, 0, 255, 0.5)".



A possible workaround would be making the child fxmls as small as possible and specifying the root position in the parent:



Identify the minimum layoutX and layoutY of the children of the inner <AnchorPane>, set those values for the root (or add them to previous values of the root) and subtract these values from all children of the the inner <AnchorPane>.



<!-- specify min layoutX/Y as position for root -->
<AnchorPane xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1"
layoutX="268"
layoutY="200"
fx:controller="mailbox.ButtonController">
<children>
<AnchorPane>
<children>
<!-- subtract root layoutX/Y from positions -->
<Button id="scrivi" mnemonicParsing="false" prefHeight="27.0"
prefWidth="65.0" text="Scrivi" />
<Button id="reply" layoutX="74" mnemonicParsing="false"
prefHeight="27.0" prefWidth="65.0" text="Reply" />
<Button id="replyall" layoutX="152" mnemonicParsing="false"
prefHeight="27.0" prefWidth="75.0" text="Reply-All" />
<Button id="forward" layoutX="243" mnemonicParsing="false"
prefHeight="27.0" prefWidth="75.0" text="Forward" />
</children>
</AnchorPane>
</children>
</AnchorPane>


(Proceed accordingly with the other fxmls.)



It is still a terrible idea overlay nodes this way, since you're using absolute positions and any modification of one of the fxmls could require you to update multiple others to avoid overlays. Even worse looks different depending on the OS/settings. For one OS the scene could look fine, on another one one your nodes could overlap.

For this reason I recommend avoiding using absolute positioning, unless you're 100% sure the node sizes are known. A scene like the one shown is better created using BorderPane/HBox/VBox and/or GridPane...







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 at 15:30

























answered Nov 20 at 12:36









fabian

50.2k115171




50.2k115171












  • Thank you very much! Now the only thing I cannot select is the list view, if I understood your code correctly, you've set the dimension of the AnchorPane by looking at where the first button is? So for the list view I should select a layoutX="1.0"and a layoutY="31.0"?
    – Samoa Joe
    Nov 20 at 13:30










  • @SamoaJoe button.fxml is just the topmost child. You need to make sure no child after the one containing the ListView covers the ListView. This is done by identifying the leftmost coordinate (minimum layoutX) and topmost coordinate (minimum layoutY), setting these values for the fxml root and subtracting them from the properties of all elements contained in the pane.
    – fabian
    Nov 20 at 15:27










  • And should I consider the prefHeight and the prefWidth of the elements? Or just the layouts?
    – Samoa Joe
    Nov 20 at 15:39










  • We're trying to find the appropriate top left coordinate of the container, so no, width and height are irrelevant.
    – fabian
    Nov 20 at 16:04










  • I found the problem, which is the textArea. I tried to edit it like this <AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextAreaController"> <children> <AnchorPane> <children> <TextArea id="textarea" layoutX="255.0" layoutY="255.0" prefHeight="144.0" prefWidth="330.0" /> </children> </AnchorPane> </children> </AnchorPane> <br> In Scene Builder it shows that the AnchorPane is way bigger that the textarea. I'm gonna edit the question to show you the problem
    – Samoa Joe
    Nov 20 at 16:54




















  • Thank you very much! Now the only thing I cannot select is the list view, if I understood your code correctly, you've set the dimension of the AnchorPane by looking at where the first button is? So for the list view I should select a layoutX="1.0"and a layoutY="31.0"?
    – Samoa Joe
    Nov 20 at 13:30










  • @SamoaJoe button.fxml is just the topmost child. You need to make sure no child after the one containing the ListView covers the ListView. This is done by identifying the leftmost coordinate (minimum layoutX) and topmost coordinate (minimum layoutY), setting these values for the fxml root and subtracting them from the properties of all elements contained in the pane.
    – fabian
    Nov 20 at 15:27










  • And should I consider the prefHeight and the prefWidth of the elements? Or just the layouts?
    – Samoa Joe
    Nov 20 at 15:39










  • We're trying to find the appropriate top left coordinate of the container, so no, width and height are irrelevant.
    – fabian
    Nov 20 at 16:04










  • I found the problem, which is the textArea. I tried to edit it like this <AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextAreaController"> <children> <AnchorPane> <children> <TextArea id="textarea" layoutX="255.0" layoutY="255.0" prefHeight="144.0" prefWidth="330.0" /> </children> </AnchorPane> </children> </AnchorPane> <br> In Scene Builder it shows that the AnchorPane is way bigger that the textarea. I'm gonna edit the question to show you the problem
    – Samoa Joe
    Nov 20 at 16:54


















Thank you very much! Now the only thing I cannot select is the list view, if I understood your code correctly, you've set the dimension of the AnchorPane by looking at where the first button is? So for the list view I should select a layoutX="1.0"and a layoutY="31.0"?
– Samoa Joe
Nov 20 at 13:30




Thank you very much! Now the only thing I cannot select is the list view, if I understood your code correctly, you've set the dimension of the AnchorPane by looking at where the first button is? So for the list view I should select a layoutX="1.0"and a layoutY="31.0"?
– Samoa Joe
Nov 20 at 13:30












@SamoaJoe button.fxml is just the topmost child. You need to make sure no child after the one containing the ListView covers the ListView. This is done by identifying the leftmost coordinate (minimum layoutX) and topmost coordinate (minimum layoutY), setting these values for the fxml root and subtracting them from the properties of all elements contained in the pane.
– fabian
Nov 20 at 15:27




@SamoaJoe button.fxml is just the topmost child. You need to make sure no child after the one containing the ListView covers the ListView. This is done by identifying the leftmost coordinate (minimum layoutX) and topmost coordinate (minimum layoutY), setting these values for the fxml root and subtracting them from the properties of all elements contained in the pane.
– fabian
Nov 20 at 15:27












And should I consider the prefHeight and the prefWidth of the elements? Or just the layouts?
– Samoa Joe
Nov 20 at 15:39




And should I consider the prefHeight and the prefWidth of the elements? Or just the layouts?
– Samoa Joe
Nov 20 at 15:39












We're trying to find the appropriate top left coordinate of the container, so no, width and height are irrelevant.
– fabian
Nov 20 at 16:04




We're trying to find the appropriate top left coordinate of the container, so no, width and height are irrelevant.
– fabian
Nov 20 at 16:04












I found the problem, which is the textArea. I tried to edit it like this <AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextAreaController"> <children> <AnchorPane> <children> <TextArea id="textarea" layoutX="255.0" layoutY="255.0" prefHeight="144.0" prefWidth="330.0" /> </children> </AnchorPane> </children> </AnchorPane> <br> In Scene Builder it shows that the AnchorPane is way bigger that the textarea. I'm gonna edit the question to show you the problem
– Samoa Joe
Nov 20 at 16:54






I found the problem, which is the textArea. I tried to edit it like this <AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mailbox.TextAreaController"> <children> <AnchorPane> <children> <TextArea id="textarea" layoutX="255.0" layoutY="255.0" prefHeight="144.0" prefWidth="330.0" /> </children> </AnchorPane> </children> </AnchorPane> <br> In Scene Builder it shows that the AnchorPane is way bigger that the textarea. I'm gonna edit the question to show you the problem
– Samoa Joe
Nov 20 at 16:54




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391994%2fanchorpane-elements-ignore-mouse-click%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin