1
2
3
4
5
6
7
8
9
10
11 package com.jsql.view.swing.tab;
12
13 import com.jsql.util.LogLevelUtil;
14 import com.jsql.view.swing.action.HotkeyUtil;
15 import org.apache.logging.log4j.LogManager;
16 import org.apache.logging.log4j.Logger;
17
18 import javax.swing.*;
19 import java.awt.*;
20
21
22
23
24 public class TabbedPaneWheeled extends JTabbedPane {
25
26 private static final Logger LOGGER = LogManager.getRootLogger();
27
28
29
30
31 public TabbedPaneWheeled() {
32 this(SwingConstants.TOP);
33 }
34
35 public TabbedPaneWheeled(int tabPlacement) {
36 super(tabPlacement, JTabbedPane.SCROLL_TAB_LAYOUT);
37 this.addMouseWheelListener(new TabbedPaneMouseWheelListener());
38 HotkeyUtil.addShortcut(this);
39 }
40
41
42
43
44 public void setBold(String label) {
45 int tabIndex = this.indexOfTab(label);
46
47 if (
48 this.getSelectedIndex() != tabIndex
49 && 0 <= tabIndex && tabIndex < this.getTabCount()
50 ) {
51 var tabHeader = this.getTabComponentAt(tabIndex);
52
53 try {
54 tabHeader.setFont(tabHeader.getFont().deriveFont(Font.BOLD));
55 } catch (ClassCastException e) {
56 LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
57 }
58 }
59 }
60 }