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
27
28
29 private static final Logger LOGGER = LogManager.getRootLogger();
30
31
32
33
34 public TabbedPaneWheeled() {
35 this(SwingConstants.TOP);
36 }
37
38 public TabbedPaneWheeled(int tabPlacement) {
39 super(tabPlacement, JTabbedPane.SCROLL_TAB_LAYOUT);
40 this.addMouseWheelListener(new TabbedPaneMouseWheelListener());
41 HotkeyUtil.addShortcut(this);
42 }
43
44
45
46
47 public void setBold(String label) {
48 int tabIndex = this.indexOfTab(label);
49
50 if (
51 this.getSelectedIndex() != tabIndex
52 && 0 <= tabIndex && tabIndex < this.getTabCount()
53 ) {
54 var tabHeader = this.getTabComponentAt(tabIndex);
55
56 try {
57 tabHeader.setFont(tabHeader.getFont().deriveFont(Font.BOLD));
58 } catch (ClassCastException e) {
59 LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
60 }
61 }
62 }
63 }