出于某种原因,当我使用setOnMouseEntered / Exited时会发生闪烁效果
有什么想法吗?在删除killThis之前,它不应该等我离开按钮。 另外,作为一个注释,按钮不在killThis下,因此不是问题。
button.setOnMouseEntered(new EventHandler<MouseEvent>
() {
public void handle(MouseEvent t)
{
killThis = cardDrawer.drawCard(button.getCardID());
layout.getChildren().add(killThis);
}
});
//Exit hover over button
button.setOnMouseExited(new EventHandler<MouseEvent>
() {
public void handle(MouseEvent t)
{
layout.getChildren().remove(killThis);
}
});
这是使用drawCard();
加载的内容public StackPane drawCard(int I)
{
StackPane cardViewer= new StackPane();
CardList cards= new CardList();
ImageView background = new ImageView(new Image(getClass().getResourceAsStream(cards.getCardList()[I].getBackgroundID())));
ImageView frame = new ImageView(new Image(getClass().getResourceAsStream(cards.getCardList()[I].getFrameID())));
ImageView nameFrame = new ImageView(new Image(getClass().getResourceAsStream(cards.getCardList()[I].getNameID())));
ImageView valueFrame = new ImageView(new Image(getClass().getResourceAsStream(cards.getCardList()[I].getValueID())));
Text textName = new Text(cards.getCardList()[I].getName());
Text textMana = new Text(""+ cards.getCardList()[I].getManaCost());
textName.setFont(Font.font("Verdana",FontWeight.BOLD, 20));
ImageView attackBoarder = new ImageView(new Image(getClass().getResourceAsStream(cards.getCardList()[I].getAttackBoarderID())));
ImageView healthBoarder = new ImageView(new Image(getClass().getResourceAsStream(cards.getCardList()[I].getHealthBoarderID())));
Text textHealth = new Text("" + cards.getCardList()[I].getActHealth());
textHealth.setFill(Color.RED);
Text textAttack = new Text("" + cards.getCardList()[I].getActAttack());
textName.setTranslateY(-225);
frame.setTranslateY(-50);
nameFrame.setTranslateY(-225);
valueFrame.setTranslateX(-175);
valueFrame.setTranslateY(-200);
textMana.setTranslateX(-175);
textMana.setTranslateY(-200);
healthBoarder.setTranslateX(185);
healthBoarder.setTranslateY(125);
attackBoarder.setTranslateX(-185);
attackBoarder.setTranslateY(125);
textHealth.setTranslateX(185);
textHealth.setTranslateY(125);
textAttack.setTranslateX(-185);
textAttack.setTranslateY(125);
cardViewer.getChildren().add(background);
cardViewer.getChildren().add(frame);
cardViewer.getChildren().add(nameFrame);
cardViewer.getChildren().add(textName);
cardViewer.getChildren().add(valueFrame);
cardViewer.getChildren().add(attackBoarder);
cardViewer.getChildren().add(healthBoarder);
cardViewer.getChildren().add(textHealth);
cardViewer.getChildren().add(textAttack);
cardViewer.getChildren().add(textMana);
return cardViewer;
}
编辑:所以我决定将killThis移到右边框,问题解决了,但是节点并没有妨碍按钮。有什么想法吗?
对于最小,完整和可验证的部分也很抱歉,只需要输入很多代码,我认为这是一个快速修复。 :P