View Javadoc
1   /*******************************************************************************
2    * Copyhacked (H) 2012-2020.
3    * This program and the accompanying materials
4    * are made available under no term at all, use it like
5    * you want, but share and discuss about it
6    * every time possible with every body.
7    *
8    * Contributors:
9    *      ron190 at ymail dot com - initial implementation
10   *******************************************************************************/
11  package com.jsql.view.swing.ui;
12  
13  import com.jsql.view.swing.util.UiUtil;
14  
15  import javax.swing.*;
16  import javax.swing.plaf.UIResource;
17  import javax.swing.plaf.basic.BasicArrowButton;
18  import javax.swing.plaf.metal.MetalTabbedPaneUI;
19  import java.awt.*;
20  
21  /**
22   * Tab UI to remove inner borders on empty tabbedpane and force header height on Linux.
23   */
24  public class BorderlessTabButtonUI extends MetalTabbedPaneUI {
25      
26      @Override
27      protected JButton createScrollButton(int direction) {
28          
29          if (direction != SOUTH && direction != NORTH && direction != EAST && direction != WEST) {
30              
31              throw new IllegalArgumentException("Direction must be one of: SOUTH, NORTH, EAST or WEST");
32          }
33  
34          return new ScrollableTabButton(direction);
35      }
36      
37      private static class ScrollableTabButton extends BasicArrowButton implements UIResource, SwingConstants {
38          
39          public ScrollableTabButton(int direction) {
40              
41              super(
42                  direction,
43                  UiUtil.COLOR_DEFAULT_BACKGROUND,
44                  UIManager.getColor("TabbedPane.darkShadow"),
45                  new Color(122, 138, 153),
46                  UIManager.getColor("TabbedPane.highlight")
47              );
48              
49              this.setBorder(BorderFactory.createEmptyBorder());
50              this.setOpaque(false);
51              this.setBorderPainted(false);
52          }
53      }
54  }