44import java .awt .Component ;
55import java .awt .FlowLayout ;
66import java .awt .Rectangle ;
7- import java .awt .event .InputEvent ;
87import java .awt .event .MouseAdapter ;
98import java .awt .event .MouseEvent ;
109import java .awt .event .MouseListener ;
1615import javax .swing .JPopupMenu ;
1716import javax .swing .JTabbedPane ;
1817import javax .swing .SwingUtilities ;
18+
19+ import com .github .weisj .darklaf .components .CloseButton ;
1920import the .bytecode .club .bytecodeviewer .BytecodeViewer ;
2021import the .bytecode .club .bytecodeviewer .gui .components .ButtonHoverAnimation ;
2122import the .bytecode .club .bytecodeviewer .gui .components .MaxWidthJLabel ;
@@ -84,7 +85,7 @@ public TabbedPane(int tabIndex, String tabWorkingName, String fileContainerName,
8485 // add more space between the label and the button
8586 label .setBorder (BorderFactory .createEmptyBorder (0 , 0 , 0 , 5 ));
8687 // tab button
87- JButton exitButton = new TabExitButton ( this , tabIndex , tabWorkingName );
88+ JButton exitButton = new CloseButton ( );
8889 this .add (exitButton );
8990 // add more space to the top of the component
9091 setBorder (BorderFactory .createEmptyBorder (2 , 0 , 0 , 0 ));
@@ -101,34 +102,24 @@ public TabbedPane(int tabIndex, String tabWorkingName, String fileContainerName,
101102 exitButton .setComponentPopupMenu (rightClickMenu );
102103 exitButton .addMouseListener (new MouseClickedListener (e ->
103104 {
104- if (e .getModifiersEx () != InputEvent .ALT_DOWN_MASK || System .currentTimeMillis () - lastMouseClick < 100 )
105- return ;
106-
107- lastMouseClick = System .currentTimeMillis ();
108- final int i = existingTabs .indexOfTabComponent (TabbedPane .this );
109- if (i != -1 )
110- existingTabs .remove (i );
105+ if (this .getTabIndex () != -1 )
106+ existingTabs .remove (this .getTabIndex ());
111107 }));
112108
113109 closeTab .addActionListener (e ->
114110 {
115- TabExitButton tabExitButton = (TabExitButton ) ((JPopupMenu )((JMenuItem ) e .getSource ()).getParent ()).getInvoker ();
116- final int index = tabExitButton .getTabIndex ();
117-
118- if (index != -1 )
119- existingTabs .remove (index );
111+ if (this .getTabIndex () != -1 )
112+ existingTabs .remove (this .getTabIndex ());
120113 });
121114 closeAllTabs .addActionListener (e ->
122115 {
123- TabExitButton tabExitButton = (TabExitButton ) ((JPopupMenu )((JMenuItem ) e .getSource ()).getParent ()).getInvoker ();
124- final int index = tabExitButton .getTabIndex ();
125-
116+
126117 while (true )
127118 {
128119 if (existingTabs .getTabCount () <= 1 )
129120 return ;
130121
131- if (index != 0 )
122+ if (this . getTabIndex () != 0 )
132123 existingTabs .remove (0 );
133124 else
134125 existingTabs .remove (1 );
@@ -257,5 +248,8 @@ public void onMousePressed(MouseEvent e)
257248 }
258249
259250 private static final long serialVersionUID = -4774885688297538774L ;
260-
251+
252+ public int getTabIndex () {
253+ return tabs .indexOfTabComponent (this );
254+ }
261255}
0 commit comments