Simple text editor implementation in java