JFXButton在启动后看起来很容易点击

问题描述 投票:0回答:1

我的一个菜单按钮(左)看起来已经在start.enter image description here之后点击或突出显示

我没有附加到这些按钮的任何操作,所以当我点击这个按钮时,一切都开始看起来应该如此

所有三个按钮看起来都一样:

  <JFXButton layoutX="14.0" layoutY="122.0" prefHeight="48.0" prefWidth="101.0" style="-fx-background-color: #f72241; -fx-background-radius: 100;" text="M/M(a,b)/1" textFill="WHITE">
     <font>
        <Font size="15.0" />
     </font>
  </JFXButton>
  <JFXButton layoutX="150.0" layoutY="122.0" prefHeight="48.0" prefWidth="101.0" style="-fx-background-color: #f72241; -fx-background-radius: 100;" text="M/M(a,b)/c" textFill="WHITE">
     <font>
        <Font size="15.0" />
     </font>
  </JFXButton>
  <JFXButton layoutX="285.0" layoutY="122.0" prefHeight="48.0" prefWidth="101.0" style="-fx-background-color: #f72241; -fx-background-radius: 100;" text="M/GI(1,s)/1" textFill="WHITE">
     <font>
        <Font size="15.0" />
     </font>
  </JFXButton>
java user-interface javafx desktop scenebuilder
1个回答
3
投票

这是焦点!

有两个解决方案:

重点放在显示的其他东西上。

button.sceneProperty().addListener((obs, ov, nv) -> {
    if(nv != null)
        nv.requestFocus();
});

或者将焦点遍历设置为false

button.setFocusTraversable(false);

您也可以在fxml中设置焦点遍历。

© www.soinside.com 2019 - 2024. All rights reserved.