void updateTabButton(int index, int selectedIndex, int buttonsCount) { if (buttonsCount == 1) { tabButton.setFocusable(false); tabButton.setCursor(Cursor.getDefaultCursor()); setBackground(BACKGROUND_COLOR_NORMAL); setBorder( TabbedCaptionBorder.get( BORDER_COLOR_NORMAL, BORDER_COLOR_NORMAL, COLOR_NONE, COLOR_NONE)); } else if (index == selectedIndex) { tabButton.setFocusable(true); tabButton.setCursor(Cursor.getDefaultCursor()); setBackground(BACKGROUND_COLOR_HIGHLIGHT); setBorder( TabbedCaptionBorder.get( BORDER_COLOR_HIGHLIGHT, BORDER_COLOR_HIGHLIGHT, COLOR_NONE, BORDER_COLOR_HIGHLIGHT)); } else { tabButton.setFocusable(true); tabButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); setBackground(BACKGROUND_COLOR_NORMAL); Color topColor = BORDER_COLOR_NORMAL; Color leftColor = index == 0 ? BORDER_COLOR_NORMAL : null; Color bottomColor = BORDER_COLOR_HIGHLIGHT; Color rightColor = index == selectedIndex - 1 ? null : index == buttonsCount - 1 ? COLOR_NONE : TABS_SEPARATOR; setBorder(TabbedCaptionBorder.get(topColor, leftColor, bottomColor, rightColor)); } }
TabButtonContainer(TabButton tabButton) { this.tabButton = tabButton; setOpaque(true); setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0)); setBackground(BACKGROUND_COLOR_NORMAL); setBorder(TabbedCaptionBorder.get(null, null, null, null)); add(tabButton, BorderLayout.CENTER); }