Merge pull request #371 from sschr15/master

fix bugs occurring on Windows when trying to generate the method list
This commit is contained in:
Konloch 2021-11-14 12:05:37 -08:00 committed by GitHub
commit 75f025134d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 2 deletions

View File

@ -1,9 +1,12 @@
package the.bytecode.club.bytecodeviewer.gui.components;
import java.awt.Component;
import java.util.List;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.BytecodeViewPanel;
import the.bytecode.club.bytecodeviewer.gui.util.BytecodeViewPanelUpdater;
import the.bytecode.club.bytecodeviewer.util.MethodParser;
@ -44,8 +47,16 @@ public class MethodsRenderer extends JLabel implements ListCellRenderer<Object>
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
boolean cellHasFocus)
{
MethodParser methods = bytecodeViewPanelUpdater.viewer.methods.get(bytecodeViewPanelUpdater.bytecodeViewPanel.decompiler.ordinal());
MethodParser.Method method = methods.getMethod((Integer) value);
int methodIndex = (Integer) value;
MethodParser methods;
List<MethodParser> methodParsers = bytecodeViewPanelUpdater.viewer.methods;
BytecodeViewPanel bytecodeViewPanel = bytecodeViewPanelUpdater.bytecodeViewPanel;
try {
methods = methodParsers.get(bytecodeViewPanel.decompiler.ordinal());
} catch (ArrayIndexOutOfBoundsException e) {
methods = methodParsers.get(bytecodeViewPanel.panelIndex);
}
MethodParser.Method method = methods.getMethod(methodIndex);
setText(method.toString());
return this;
}