英文:
JavaFX, Problem with positiong radio buttons over Stack Pane
问题
<BorderPane fx:controller="sample.Controller"
xmlns:fx="http://javafx.com/fxml"
stylesheets="@styles.css">
<top>
<TilePane alignment="center" hgap="5" vgap="5">
<padding><Insets top="5" bottom="10" left="5" right="5"/></padding>
<Button text="Europa" />
<Button text="Afryka" />
<Button text="Azja" id="button_three" />
<Button text="Australia" />
<Button text="Ameryka Północna" />
<Button text="Ameryka Południowa"/>
</TilePane>
</top>
<center>
<StackPane id="Europa" prefWidth="700" prefHeight="650" >
<RadioButton text="Londyn" />
<RadioButton text="Warszawa"/>
</StackPane>
</center>
<bottom>
</bottom>
<right>
<VBox alignment="CENTER_LEFT">
<Label text="Your City :" />
<Label text="Time in your City :" />
</VBox>
</right>
</BorderPane>
<center>
<StackPane id="Europa" alignment="TOP_LEFT" prefWidth="700" prefHeight="650" >
<RadioButton text="Londyn" >
<padding><Insets top="50" left="50"/></padding>
</RadioButton>
<RadioButton text="Warszawa"/>
</StackPane>
</center>
英文:
I've doing some application for checking time on the world. I want use Radio Buttons over the map of the world for representing Cities. But I have a problem with positioning this buttons over my World Map. There is my fxml file. How can i move this button for the amount px I want. There is my FXML file. I set stack Pane background image in css file. In main.java I only set app to not be resizable.
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.TilePane?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Label?>
<BorderPane fx:controller="sample.Controller"
xmlns:fx="http://javafx.com/fxml"
stylesheets="@styles.css">
<top>
<TilePane alignment="center" hgap="5" vgap="5">
<padding><Insets top="5" bottom="10" left="5" right="5"/></padding>
<Button text="Europa" />
<Button text="Afryka" />
<Button text="Azja" id="button_three" />
<Button text="Australia" />
<Button text="Ameryka Północna" />
<Button text="Ameryka Południowa"/>
</TilePane>
</top>
<center>
<StackPane id="Europa" prefWidth="700" prefHeight="650" >
<RadioButton text="Londyn" />
<RadioButton text="Warszawa"/>
</StackPane>
</center>
<bottom>
</bottom>
<right>
<VBox alignment="CENTER_LEFT">
<Label text="Your City :"/>
<Label text="Time in your City :"/>
</VBox>
</right>
</BorderPane>
Also when I tried positioning like that it works but space over the button and on the left also activates button so I guess it is not a proper way
<center>
<StackPane id="Europa" alignment="TOP_LEFT" prefWidth="700" prefHeight="650" >
<RadioButton text="Londyn" >
<padding><Insets top="50" left="50"/></padding>
</RadioButton>
<RadioButton text="Warszawa"/>
</StackPane>
</center>
答案1
得分: 0
我找到了答案。在堆叠面板中,要移动我的按钮,我必须正确操作X和Y轴。在FXML文件中,正确的做法例如:
<RadioButton text="Warszawa" translateX="500" translateY="100"/>
英文:
I've found the answer. In the Stack Pane to move my buttons i have to operate X an Y axis the proper way to do that in FXML file is for example:
<RadioButton text="Warszawa" translateX="500" translateY="100"/>
专注分享java语言的经验与见解,让所有开发者获益!
评论