diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JFrameConsole.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JFrameConsole.java index 8bf0502b..3800aec2 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JFrameConsole.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/JFrameConsole.java @@ -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; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ShowAllStrings.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ShowAllStrings.java index 700a351c..cc1f2cc4 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ShowAllStrings.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ShowAllStrings.java @@ -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); } } \ No newline at end of file