views:

80

answers:

2

Hi,

Using JTabbedPane we want to implement a design that requires tabs to be overlapping (illustrated in image that can be found here: http://imm.io/YAZ).

Not exactly rocket science, but I can't seem to find a solution (not even after extensive googling).

Is this possible using JTabbedPane (via PLAF maybe) or do we need to write a custom component?

Thanks
Tomas

A: 

As far as I know it requires a custom component. I think it can be done by extending the JTabbedPane and inserting a new type of tab.

The way you make it overlap is by calling the paintComponent method on the selected tab last i.e. it will be closest to the front of the view.

As for the overlapping tab class you can make use of almost any JComponent subclass for your code. You can even theme it with transparent PNG's as background and calling public void setOpaque(boolean isOpaque) on the tab itself.

Jes
A: 

Solved this by overriding paintTab in a custom UI implementation and painting part of the previous tab over the next. This was possible since paintTab allows you to paint over the entire tab area, not solely in the bounds of the tab it was currently painting. Example, if we have tabs A, B and C:

Tab A paints its left border and center fill. Tab B paints its left border, center fill and then tab A's right border. Tab C paints its left border, center fill, Tab B's right border and then it's own right border (since this is the last tab in the pane).

Then handle selected tabs slightly differently.

The above solution was not hard to implement and works very well.

Tomas Mazowski