How can I drag tabs in JTabbedPane

左心房为你撑大大i 提交于 2019-12-08 12:00:43

问题


I am trying to create a JTabbedPane with tabs arranged vertically LEFT with SCROLL_TAB_LAYOUT. The code snippet for this is as below:


private Component createTabbedPane() 
{
 JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT,
  JTabbedPane.SCROLL_TAB_LAYOUT);
 for (int i = 0; i < 20; i++) {
  JPanel pane = new JPanel();
  pane.add(new JLabel("This is Panel " + i));
  tabbedPane.addTab("Tab " + i, pane);
 }
 return tabbedPane;
}

However, I want have the same scrolling feature with mouse dragged so that it could be used for touch screen. Is there any way to use mouse listeners on the tabs?


回答1:


You can add mouseListners to the tabs themselves or to the tab components.



来源:https://stackoverflow.com/questions/4376084/how-can-i-drag-tabs-in-jtabbedpane

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!