2016-11-10 14 views
1

JavaFXでマーキーアニメーションに問題があります。私は3つのノードを持つHBoxを持っていて、2番目のノードにはテキストノードがありますが、それはマーキー変換が必要ですが、テキストが2番目のノードから出てきたら表示されません。JavaFXマーキーがノードから外に出る

画像を設定して問題を表示します(テキストは白い領域に表示されます)。

text introduces inside white node

私のhboxコード:

HBox bill = new HBox(0); 
    bill.getChildren().addAll(logoPane,product,total); 
    bill.setBackground(new Background(new BackgroundFill(Color.web("#FFFFFF"), CornerRadii.EMPTY, Insets.EMPTY))); 
    bill.setHgrow(product, Priority.ALWAYS); 

アニメーション:

timelineAnimation = new Timeline(); 
    final KeyValue kv = new KeyValue(productLabel.translateXProperty(), -1000); 
    final KeyFrame kf = new KeyFrame(Duration.millis(2000), kv); 
    timelineAnimation.getKeyFrames().add(kf); 

そして、どのように私は私の製品ノードを定義します。

productLabel.setFont(new Font("Times New Roman",30)); 

    product = new StackPane(); 
    product.setMaxWidth(2000); 
    product.setMaxHeight(100); 
    product.setMinWidth(574); 
    product.setMinHeight(100); 

    product.getChildren().add(productLabel); 
    product.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY))); 
    product.setAlignment(productLabel, Pos.CENTER); 

が、それは十分にinformatたホープイオン。

ありがとうございます!

答えて

1

は単にRectangleproductペインのためのclipとしてを追加し、それがペインのサイズにサイズですバインド:

Rectangle clip = new Rectangle(); 
product.layoutBoundsProperty().addListener((observable, oldValue, newValue) -> { 
    clip.setWidth(newValue.getWidth()); 
    clip.setHeight(newValue.getHeight()); 
}); 
product.setClip(clip); 

これはproductのない子孫がこのノードの境界の外側に描画されていないことを確認します。

+0

ニース、それは動作します!ありがとう@fabian – accnono

関連する問題