01: /*
02: * BorderLessMotifTabbedPaneUI.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.gui.components;
13:
14: import java.awt.Color;
15: import java.awt.Graphics;
16: import java.awt.Insets;
17:
18: import javax.swing.JTabbedPane;
19: import javax.swing.UIManager;
20:
21: import com.sun.java.swing.plaf.motif.MotifTabbedPaneUI;
22:
23: public class BorderLessMotifTabbedPaneUI extends MotifTabbedPaneUI {
24: private Color selColor;
25:
26: protected Insets getContentBorderInsets(int tabPlacement) {
27: return TabbedPaneUIFactory.getBorderLessInsets(tabPlacement);
28: }
29:
30: protected void installDefaults() {
31: super .installDefaults();
32: selColor = UIManager.getColor("TabbedPane.selected");
33: }
34:
35: protected void paintContentBorder(Graphics g, int tabPlacement,
36: int selectedIndex) {
37: int width = tabPane.getWidth();
38: int height = tabPane.getHeight();
39: Insets insets = tabPane.getInsets();
40:
41: int x = insets.left;
42: int y = insets.top;
43: int w = width - insets.right - insets.left;
44: int h = height - insets.top - insets.bottom;
45:
46: switch (tabPlacement) {
47: case LEFT:
48: x += calculateTabAreaWidth(tabPlacement, runCount,
49: maxTabWidth);
50: w -= (x - insets.left);
51: break;
52: case RIGHT:
53: w -= calculateTabAreaWidth(tabPlacement, runCount,
54: maxTabWidth);
55: break;
56: case BOTTOM:
57: h -= calculateTabAreaHeight(tabPlacement, runCount,
58: maxTabHeight);
59: break;
60: case TOP:
61: default:
62: y += calculateTabAreaHeight(tabPlacement, runCount,
63: maxTabHeight);
64: h -= (y - insets.top);
65: }
66: // Fill region behind content area
67: if (selColor == null) {
68: g.setColor(tabPane.getBackground());
69: } else {
70: g.setColor(selColor);
71: }
72: g.fillRect(x, y, w, h);
73:
74: switch (tabPlacement) {
75: case JTabbedPane.TOP:
76: paintContentBorderTopEdge(g, tabPlacement, selectedIndex,
77: x, y, w, h);
78: break;
79: case JTabbedPane.BOTTOM:
80: paintContentBorderBottomEdge(g, tabPlacement,
81: selectedIndex, x, y, w, h);
82: break;
83: case JTabbedPane.LEFT:
84: paintContentBorderLeftEdge(g, tabPlacement, selectedIndex,
85: x, y, w, h);
86: break;
87: case JTabbedPane.RIGHT:
88: paintContentBorderRightEdge(g, tabPlacement, selectedIndex,
89: x, y, w, h);
90: break;
91: }
92: }
93: }
|