This commit is contained in:
huangyuhui
2016-02-28 13:43:03 +08:00
parent f811d4c89f
commit d10a7fad20
6 changed files with 20 additions and 12 deletions

View File

@@ -66,6 +66,14 @@ public class ProcessThread extends Thread {
line = "";
} else
line += (char) ch;
while ((ch = br.read()) != -1)
if (ch == '\n') {
printlnEvent.execute(line);
System.out.println("Minecraft: " + line);
p.getStdOutLines().add(line);
line = "";
} else
line += (char) ch;
stopEvent.execute(p);
} catch (Exception e) {
HMCLog.err("An error occured when reading process stdout/stderr.", e);

View File

@@ -21,6 +21,7 @@ import java.awt.Component;
import java.awt.EventQueue;
import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.Window;
import java.io.File;
import java.io.IOException;
import java.net.URI;
@@ -279,13 +280,13 @@ public class SwingUtils {
component.setEnabled(t);
}
public static void exitIfNoWindow(Frame thisFrame) {
public static void exitIfNoWindow(Window thisFrame) {
exitIfNoWindow(thisFrame, false);
}
public static void exitIfNoWindow(Frame thisFrame, boolean neededDispose) {
public static void exitIfNoWindow(Window thisFrame, boolean neededDispose) {
boolean flag = false;
for (Frame f : Frame.getFrames()) {
for (Window f : Window.getWindows()) {
if (f == thisFrame)
continue;
if (f.isVisible())

View File

@@ -17,13 +17,9 @@
*/
package org.jackhuang.hellominecraft.util.ui;
import java.awt.Frame;
import java.awt.HeadlessException;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JDialog;
import org.jackhuang.hellominecraft.util.StrUtils;
import org.jackhuang.hellominecraft.util.logging.Level;
@@ -31,14 +27,15 @@ import org.jackhuang.hellominecraft.util.logging.Level;
*
* @author huangyuhui
*/
public class WebFrame extends JFrame {
public class WebFrame extends JDialog {
public WebFrame(String... strs) {
this(("<html>" + StrUtils.parseParams(t -> ("<font color='#" + GraphicsUtils.getColor(Level.guessLevel((String) t, Level.INFO).COLOR) + "'>"), strs, t -> "</font><br />") + "</html>")
.replace(" ", "&nbsp;").replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;"));
}
public WebFrame(String content) throws HeadlessException {
public WebFrame(String content) {
super((JDialog) null, false);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {