mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
- An alternate NPE fix as suggested by Max.
This commit is contained in:
@@ -5,6 +5,8 @@ import javax.swing.SwingUtilities;
|
|||||||
|
|
||||||
import forge.gui.toolbox.FSkin.SkinnedEditorPane;
|
import forge.gui.toolbox.FSkin.SkinnedEditorPane;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Viewer for HTML
|
* Viewer for HTML
|
||||||
*
|
*
|
||||||
@@ -33,7 +35,12 @@ public class FHtmlViewer extends SkinnedEditorPane {
|
|||||||
public void setText(final String text) {
|
public void setText(final String text) {
|
||||||
SwingUtilities.invokeLater( new Runnable() { //need to invokeLater to avoid flicker
|
SwingUtilities.invokeLater( new Runnable() { //need to invokeLater to avoid flicker
|
||||||
public void run() {
|
public void run() {
|
||||||
setSuperText(null == text ? "" : text.replaceAll("(\r\n)|(\n)", "<br>")); //replace line breaks with <br> elements
|
if ( StringUtils.isBlank(text) ) {
|
||||||
|
setSuperText("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setSuperText(text.replaceAll("(\r\n)|(\n)", "<br>")); //replace line breaks with <br> elements
|
||||||
setCaretPosition(0); //keep scrolled to top
|
setCaretPosition(0); //keep scrolled to top
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user