diff --git a/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/Console.java b/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/Console.java index a420e03..f987eba 100644 --- a/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/Console.java +++ b/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/Console.java @@ -5,23 +5,21 @@ import net.knarcraft.minecraftserverlauncher.Main; import javax.swing.*; import javax.swing.text.DefaultCaret; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; +import java.awt.event.*; import java.util.ArrayList; import static javax.swing.text.DefaultCaret.ALWAYS_UPDATE; /** * Acts as a single writable/readable tab - * Has a box for user input, and a textArea for server output. + * + *

Has a box for user input, and a textArea for server output.

* * @author Kristian Knarvik * @version 1.0.0 * @since 1.0.0 */ -public class Console implements ActionListener, KeyListener { +public class Console extends KeyAdapter implements ActionListener, KeyListener { private final JTextField textInput; private final JTextArea textOutput; private final String name; @@ -29,6 +27,12 @@ public class Console implements ActionListener, KeyListener { private final ArrayList commands = new ArrayList<>(); private int commandIndex; + /** + * Instantiates a new console + * + * @param tab

The tabbed pane used for displaying the console

+ * @param name

The name of the console tab

+ */ Console(JTabbedPane tab, String name) { this.name = name; panel = new JPanel(); @@ -48,14 +52,19 @@ public class Console implements ActionListener, KeyListener { textInput.addKeyListener(this); } + /** + * Gets the JPanel this console is drawn on + * + * @return

The JPanel this console is drawn on

+ */ public JPanel getPanel() { return this.panel; } /** - * Prints a string to the textArea. + * Prints a string to the console's output * - * @param text The text to print + * @param text

The string to print

*/ public void output(String text) { this.textOutput.setText(this.textOutput.getText() + "\n" + text); @@ -86,14 +95,6 @@ public class Console implements ActionListener, KeyListener { } } - @Override - public void keyReleased(KeyEvent e) { - } - - @Override - public void keyTyped(KeyEvent e) { - } - /** * Shows the previously executed command in the input field *