Thank you! I followed the link, and and ended up solving it with the following code. This is a callback function for ButtonDownFcn in the edit box. Selects all text on a left-click of the mouse.
%Initialize the java engine
%Create a Robot-object to do the key-pressing
%Commands for pressing keys:
% If the text cursor isn't in the edit box allready, then it
% needs to be placed there for ctrl+a to select the text.
% Therefore, we make sure the cursor is in the edit box by
% forcing a mouse button press:
% CONTROL + A :