Reputation: 41
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?
Upvotes: 0
Views: 1630
Reputation: 23629
You can add mouseListners to the tabs themselves or to the tab components.
Upvotes: 1