Skip to content

Commit 758d6b7

Browse files
committed
Fix issue with darklaf JMenuBar.
1 parent 3ab009d commit 758d6b7

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
*
8585
* TODO DarkLAF Specific Bugs:
8686
* + Resource List creates swing lag with large project
87-
* + JMenuBar can only be displayed on a JFrame, a work around is needed for this
87+
* + JMenuBar can only be displayed on a JFrame, a work around is needed for this (Partially solved)
8888
*
8989
* TODO IN-PROGRESS:
9090
* + Resource Exporter/Save/Decompile As Zip needs to be rewritten

src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
77
import the.bytecode.club.bytecodeviewer.Configuration;
88
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ComponentViewer;
9-
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;
109
import the.bytecode.club.bytecodeviewer.resources.IconResources;
1110
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
1211
import the.bytecode.club.bytecodeviewer.gui.components.SearchableRSyntaxTextArea;
@@ -18,6 +17,7 @@
1817
import the.bytecode.club.bytecodeviewer.util.SyntaxLanguage;
1918

2019
import javax.swing.*;
20+
import javax.swing.border.LineBorder;
2121
import java.awt.*;
2222
import java.io.File;
2323
import java.io.IOException;
@@ -123,16 +123,18 @@ public void setVisible(boolean b)
123123

124124
JPanel p = new JPanel(new BorderLayout());
125125
JPanel p2 = new JPanel(new BorderLayout());
126-
127126
p.add(p2, BorderLayout.NORTH);
128127
p.add(component, BorderLayout.CENTER);
129-
130-
if(Configuration.lafTheme == LAFTheme.SYSTEM)
131-
p2.add(getJMenuBar(), BorderLayout.CENTER);
132-
else //TODO DarkLAF wont display the jMenuBar due to how it handles them, instead display the menu
133-
//TODO make the menu interactable and display the menu manually
134-
p2.add(getJMenuBar().getMenu(0), BorderLayout.CENTER);
135-
128+
129+
JMenuBar menuBar = getJMenuBar();
130+
// As the Darklaf windows decorations steal the menu bar from the frame
131+
// it sets the preferred size to (0,0). Because we want to steal the menu bar ourselves.
132+
// we have to revert this change.
133+
// Remove when https://github.com/weisJ/darklaf/issues/258 is fixed and available in a
134+
// release.
135+
menuBar.setPreferredSize(null);
136+
p2.add(menuBar, BorderLayout.CENTER);
137+
136138
ComponentViewer.addComponentAsTab(pluginName, p);
137139
}
138140
else

0 commit comments

Comments
 (0)