Console.java 563 B

123456789101112131415161718192021222324252627
  1. package ui.view;
  2. import javax.swing.JTextArea;
  3. import javax.swing.text.DefaultCaret;
  4. /**
  5. * Little new swing object to print data to a console.
  6. * @author tom
  7. *
  8. */
  9. public class Console extends JTextArea {
  10. public Console() {
  11. super();
  12. this.setEditable(false);
  13. DefaultCaret caret = (DefaultCaret)this.getCaret();
  14. caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
  15. }
  16. public void clear() {
  17. this.setText("");
  18. }
  19. public void print(String message) {
  20. this.append(message);
  21. }
  22. public void println(String message) {
  23. this.append(message + "\n");
  24. }
  25. }