开发者

How can I drag tabs in JTabbedPane

开发者 https://www.devze.com 2023-01-29 19:56 出处:网络
I am trying to create a JTabbedPane with tabs arranged vertically LEFT with SCROLL_TAB_LAYOUT. The code snippet for this is as below:

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

开发者_StackOverflow中文版

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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消