package edu.dynamic.dynamiz.UI;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

//import edu.dynamic.dynamiz.logic.Controller;
import edu.dynamic.dynamiz.controller.*;
import edu.dynamic.dynamiz.structure.Feedback;

/**
 * 
 * @author XYLau
 *
 */
public class UI extends JPanel implements ActionListener {
	protected JTextField inputScreen;
	protected JTextArea displayScreen;
	private Controller controller = new Controller();
	private final static String newline = "\n";

	public UI() {
		super(new GridBagLayout());
		displayScreen = new JTextArea(40, 100);
		displayScreen.setEditable(false);
		JScrollPane scrollPane = new JScrollPane(displayScreen);

		inputScreen = new JTextField(20);
		inputScreen.addActionListener(this);

		// Add Components to this panel.
		GridBagConstraints c = new GridBagConstraints();
		c.gridwidth = GridBagConstraints.REMAINDER;

		c.fill = GridBagConstraints.BOTH;
		c.weightx = 1.0;
		c.weighty = 1.0;
		add(scrollPane, c);

		c.fill = GridBagConstraints.HORIZONTAL;
		add(inputScreen, c);
	}

	/**
	 * Event Handler for each event, where event refers to the entry of a single
	 * command into the Screen interface
	 */
	public void actionPerformed(ActionEvent evt) {

		String text = inputScreen.getText();
		/*
		 * To be added once controller is completed (ZX) Feedback feedback =
		 * controller.executeCommand(text);
		 */
		display("Command Entered: "); // for testing purposes (XY)
		displayln(text); 
		
		// TODO: Replace with line by line string feedback once Displayer is completed (WY)

		// Additional Feature: Retained Last-Entered Command
		inputScreen.selectAll();

		// Make sure the new text is visible, even if there
		// was a selection in the text area.
		displayScreen.setCaretPosition(displayScreen.getDocument().getLength());
	}

	/**
	 * Displays a string onto the Screen with newline
	 * @param text
	 */
	public void displayln(String text) {
		displayScreen.append(text + newline);
	}

	/**
	 * Displays a string onto the Screen without a newline
	 * 
	 * @param text
	 */
	public void display(String text) {
		displayScreen.append(text);
	}

	/**
	 * Create the GUI and show it. For thread safety, this method should be
	 * invoked from the event dispatch thread.
	 */
	private static void Screen() {
		// Create and set up the window.
		JFrame frame = new JFrame("Dynamiz");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		// Add contents to the window.
		frame.add(new UI());

		displayScreen(frame);
	}

	/**
	 * Displays the screen
	 * 
	 * @param frame
	 */
	private static void displayScreen(JFrame frame) {
		frame.pack();
		frame.setVisible(true);
	}

	public static void main(String[] args) {
		// Schedule a job for the event dispatch thread:
		// creating and showing this application's GUI.
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				Screen();
			}
		});
	}
}
@@ -103,12 +103,8 @@
 *;%0D%0A
-%0D%0A//
 impo
@@ -130,117 +130,30 @@
 miz.
-logic.Controller;%0D%0Aimport edu.dynamic.dynamiz.controller.*;%0D%0Aimport edu.dynamic.dynamiz.structure.Feedback;%0D%0A
+UI.DisplayerInterface;
 %0D%0A/*
@@ -333,97 +333,96 @@
 ate 
-Controller controller = new Controller();%0D%0A%09private final static String newline = %22%5Cn%22
+final static String newline = %22%5Cn%22;%0D%0A%09public static Displayer disp = new Displayer()
 ;%0D%0A
+%09
 %0D%0A%09p
@@ -1358,27 +1358,28 @@
 lay(
-%22Command Entered: %22
+disp.displayPrompt()
 ); /
@@ -1407,16 +1407,19 @@
 s (XY)%0D%0A
+%09%0D%0A
 %09%09displa
@@ -2501,24 +2501,28 @@
 en(frame);%0D%0A
+%09%09%0D%0A
 %09%7D%0D%0A%0D%0A%09/**%0D%0A
@@ -2922,16 +2922,22 @@
 een();%0D%0A
+%09%09%09%09%0D%0A
 %09%09%09%7D%0D%0A%09%09

Integrate displayPrompt into UI.java