鼠标拖放时的JavaFX Tab定位 [英] JavaFX Tab positioning on mouse drag/drop

查看:74
本文介绍了鼠标拖放时的JavaFX Tab定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有多个标签的Tabpane. 我想通过仅将标签拖动到特定位置来重新定位标签(就像我们能够在浏览器中排列标签的方式一样.) 我有什么办法可以实现它?

I have a Tabpane with multiple tabs. I want to re-position tabs by just dragging them at a particular position(just like the way we are able to arrange tabs in browser.) Is there any way i can achieve it?

推荐答案

我们以略有不同的方式实现了此功能.我们在标签上下文菜单中提供了向左移动/向右移动"功能,而不是通过拖放功能来移动标签. 我们希望优先考虑此功能,因此现在通过此变通办法实施它.

We achieved it in a slightly different way.Instead of drag/drop feature we provided the move left/move right functionality on tab context menu which in turns moves the tab. We wanted to have this feature on priority so implemented it with this workaround for now.

public void moveRight() {
    protected TabPane workBook;
    int cTabIndex = bem.workBook.getTabs().indexOf(bem.activeSheet);
    int tabCount = workBook.getTabs().size();

    if (tabCount > 1 && cTabIndex > 0) {
        workBook.getTabs().remove(bem.activeSheet);
        workBook.getTabs().add(cTabIndex - 1, bem.activeSheet);
    }
}

这篇关于鼠标拖放时的JavaFX Tab定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆