Skip to content

Commit 7d6a945

Browse files
authored
Merge pull request #342 from weisJ/ui_fixes
UI fixes
2 parents bc19b3b + 758d6b7 commit 7d6a945

4 files changed

Lines changed: 30 additions & 11 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/gui/components/VisibleComponent.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import com.github.weisj.darklaf.icons.ThemedSVGIcon;
44
import the.bytecode.club.bytecodeviewer.Configuration;
55
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.Workspace;
6+
import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme;
67
import the.bytecode.club.bytecodeviewer.resources.IconResources;
78

9+
import javax.swing.BorderFactory;
810
import javax.swing.JInternalFrame;
911

1012
/***************************************************************************
@@ -40,7 +42,16 @@ public VisibleComponent(final String title)
4042
super(title, false, false, false, false);
4143
this.setDefaultIcon();
4244
}
43-
45+
46+
@Override
47+
public void updateUI() {
48+
if (Configuration.lafTheme != LAFTheme.SYSTEM)
49+
setBorder(BorderFactory.createEmptyBorder());
50+
else
51+
setBorder(null);
52+
super.updateUI();
53+
}
54+
4455
public void setDefaultIcon()
4556
{
4657
try {

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

src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJMenu.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,10 @@ public TranslatedJMenu(String text, TranslatedComponents translatedComponents)
4444
componentReference.translate();
4545
}
4646
}
47+
48+
@Override
49+
public boolean isEnabled()
50+
{
51+
return super.isEnabled() && getMenuComponentCount() > 0;
52+
}
4753
}

0 commit comments

Comments
 (0)