简体   繁体   English

如何在JTabbedPane中拖动标签

[英]How can I drag tabs in JTabbedPane

I am trying to create a JTabbedPane with tabs arranged vertically LEFT with SCROLL_TAB_LAYOUT. 我正在尝试创建一个JTabbedPane,其选项卡使用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? 有没有办法在选项卡上使用鼠标侦听器?

您可以将mouseListners添加到选项卡本身或选项卡组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM