aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/console
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/gui/console')
-rw-r--r--src/jcgp/gui/console/Console.java11
-rw-r--r--src/jcgp/gui/console/GUIConsole.java22
2 files changed, 29 insertions, 4 deletions
diff --git a/src/jcgp/gui/console/Console.java b/src/jcgp/gui/console/Console.java
new file mode 100644
index 0000000..63c7f5b
--- /dev/null
+++ b/src/jcgp/gui/console/Console.java
@@ -0,0 +1,11 @@
+package jcgp.gui.console;
+
+public interface Console {
+
+ public void println(String s);
+
+ public void print(String s);
+
+ public void flush();
+
+}
diff --git a/src/jcgp/gui/console/GUIConsole.java b/src/jcgp/gui/console/GUIConsole.java
index 0ef2be3..8fdb1a5 100644
--- a/src/jcgp/gui/console/GUIConsole.java
+++ b/src/jcgp/gui/console/GUIConsole.java
@@ -5,13 +5,15 @@ import javafx.scene.Cursor;
import javafx.scene.control.TextArea;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
-import jcgp.GUI;
+import jcgp.gui.GUI;
-public class GUIConsole extends AnchorPane {
+public class GUIConsole extends AnchorPane implements Console {
private boolean dragging;
private TextArea textArea = new TextArea("Welcome to JCGP!\n");
+ private StringBuffer printBuffer = new StringBuffer();
+
public GUIConsole() {
super();
textArea.setEditable(false);
@@ -87,8 +89,20 @@ public class GUIConsole extends AnchorPane {
return event.getY() < (GUI.RESIZE_MARGIN);
}
- public TextArea getTextArea() {
- return textArea;
+ @Override
+ public void println(String s) {
+ printBuffer.append(s + "\n");
+ }
+
+ @Override
+ public void print(String s) {
+ printBuffer.append(s);
+ }
+
+ @Override
+ public void flush() {
+ textArea.appendText(printBuffer.toString());
+ printBuffer = new StringBuffer();
}
}