如何使用 javafx 使用 DropDown Items 进行 sidenav?

我正在尝试使用可折叠项目制作左侧导航栏,如下所示:

如何使用 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);
    }
}

但在这两种情况下,下一项都不会向上移动。

如何使用 javafx 使用 DropDown Items 进行 sidenav?

如何使用 javafx 使用 DropDown Items 进行 sidenav?

oji6695 回答:如何使用 javafx 使用 DropDown Items 进行 sidenav?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/308.html

大家都在问