Fixed The Swing UI Freezing/Lag

This should resolve any issues when first opening a class resource or refreshing it.
This commit is contained in:
Konloch 2021-06-28 17:17:30 -07:00
parent 4e7edaada1
commit fa766a4851

View file

@ -5,9 +5,7 @@ import java.awt.Font;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.util.Objects; import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import javax.swing.JComboBox; import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.JViewport;
import javax.swing.event.CaretEvent; import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener; import javax.swing.event.CaretListener;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
@ -77,11 +75,10 @@ public abstract class PaneUpdaterThread implements Runnable
doShit(); doShit();
//freezes the UI for some reason //this used to freeze the swing UI
//probably cause BCV is doing dumb shit with the swing thread //if anything breaks again try searching here first
synchronizePane(); synchronizePane();
attachCtrlMouseWheelZoom(updateUpdaterTextArea.getScrollPane(), updateUpdaterTextArea); attachCtrlMouseWheelZoom(updateUpdaterTextArea.getScrollPane(), updateUpdaterTextArea);
} }
@ -214,8 +211,11 @@ public abstract class PaneUpdaterThread implements Runnable
return; return;
JViewport viewport = updateUpdaterTextArea.getScrollPane().getViewport(); JViewport viewport = updateUpdaterTextArea.getScrollPane().getViewport();
viewport.addChangeListener(viewportListener); SwingUtilities.invokeLater(()->
updateUpdaterTextArea.addCaretListener(caretListener); {
viewport.addChangeListener(viewportListener);
updateUpdaterTextArea.addCaretListener(caretListener);
});
final MethodParser methods = viewer.methods.get(paneIndex); final MethodParser methods = viewer.methods.get(paneIndex);
for (int i = 0; i < updateUpdaterTextArea.getLineCount(); i++) for (int i = 0; i < updateUpdaterTextArea.getLineCount(); i++)
@ -230,12 +230,16 @@ public abstract class PaneUpdaterThread implements Runnable
} }
} }
if (BytecodeViewer.viewer.showClassMethods.isSelected()) { //TODO fix this
if (!methods.isEmpty()) { if (BytecodeViewer.viewer.showClassMethods.isSelected())
{
if (!methods.isEmpty())
{
methodsList = new JComboBox<>(); methodsList = new JComboBox<>();
for (Integer line : methods.getMethodsLines()) {
for (Integer line : methods.getMethodsLines())
methodsList.addItem(line); methodsList.addItem(line);
}
methodsList.setRenderer(new MethodsRenderer(this)); methodsList.setRenderer(new MethodsRenderer(this));
methodsList.addActionListener(e -> methodsList.addActionListener(e ->
{ {