Resolved JFrameConsole Text Bug
This fixes the bug with large Strings causing the swing thread to lock up
This commit is contained in:
parent
eab804ff7f
commit
106549658f
2 changed files with 19 additions and 3 deletions
|
@ -64,7 +64,7 @@ public class JFrameConsole extends JFrame
|
|||
*/
|
||||
public void setText(String t)
|
||||
{
|
||||
textArea.setText(t);
|
||||
textArea.setText(trim(t));
|
||||
textArea.setCaretPosition(0);
|
||||
}
|
||||
|
||||
|
@ -73,5 +73,19 @@ public class JFrameConsole extends JFrame
|
|||
return textArea;
|
||||
}
|
||||
|
||||
public String trim(String s)
|
||||
{
|
||||
int len = s.length();
|
||||
int max = 500_000; //TODO this can be increased to 1,000,000 the lower number was chosen to be safe
|
||||
if(len >= max)
|
||||
{
|
||||
int skipped = len - max;
|
||||
s = s.substring(0, max);
|
||||
s += "\n\rSkipping " + skipped + " chars, allowing " + max;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -5056940543411437508L;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
|||
import the.bytecode.club.bytecodeviewer.api.Plugin;
|
||||
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||
|
||||
/***************************************************************************
|
||||
|
@ -95,8 +97,8 @@ public class ShowAllStrings extends Plugin
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
frame.appendText(sb.toString());
|
||||
|
||||
frame.setText(sb.toString());
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue