如何解决如何使用 javafx 使用 DropDown Items 进行 sidenav?
我正在尝试使用可折叠项目制作左侧导航栏,如下所示:
我尝试使用带有按钮的父 Vbox 和另一个带有项目的 vBox 来制作组件。
最后我一直在使用缩放动画,但我不知道如何在顶部设置兴趣点,现在我尝试使用翻译动画将其向上平移,
import com.jfoenix.controls.JFXButton;
import java.util.ArrayList;
import javafx.animation.ScaleTransition;
import javafx.animation.TranslateTransition;
import javafx.geometry.Insets;
import javafx.scene.layout.VBox;
import javafx.util.Duration;
public class SideCollapsableMenu extends VBox{
private VBox vBoxItems;
private JFXButton TopButton;
private TranslateTransition collapseAnimation;
public SideCollapsableMenu(String mainName,ArrayList<JFXButton> buttonList){
this.TopButton = new JFXButton(mainName);
this.vBoxItems = new VBox(0);
this.vBoxItems.setPadding(new Insets(0,20));
this.vBoxItems.getChildren().addAll(buttonList);
this.getChildren().addAll(TopButton,vBoxItems);
this.TopButton.setOnMouseClicked(event -> playCollapse());
this.collapseAnimation =
new TranslateTransition(Duration.INDEFINITE.millis(1000),vBoxItems);
this.collapseAnimation.setToY(-40*buttonList.size());
}
public void playCollapse(){
collapseAnimation.play();
vBoxItems.setVisible(false);
}
}
但在这两种情况下,下一项都不会向上移动。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。