MATLAB Answers

UIComponent JTextField Text alignment

7 views (last 30 days)
I included Yair Altman's UICOMPONENT to place a Text Field on my figure like so:
Now I would like the Text to appear center-aligned.
How can I do that? I've been trying for hours yesterday and haven't figured it out yet.
Also, if you do know how, can you perhals also tell me, where I need to look to find out such things?
Many thanks!
BR, Michael

  1 Comment

Michael Critchfield
Michael Critchfield on 29 Nov 2018
I really like this toolbox, but I still cannot change the Alignment Property for the text to be centered:
ProjectNameEdit = uicomponent('Parent',ProjectGUI,'style','JTextField',...
'position',[98 113 274 20],'Text','Enter Name');
%So far so good. Here I get an error message:
%Error: Parameter must be scalar.
I also tried 1 and true
Can someone please help me with this?

Sign in to comment.

Accepted Answer

Yair Altman
Yair Altman on 25 Dec 2018
Use JTextField.JavaPeer.CENTER or the value 0 instead of 'CENTER':
JTextField.HorizontalAlignment = JTextField.JavaPeer.CENTER; % =0

  1 Comment

Michael Critchfield
Michael Critchfield on 26 Dec 2018
Thanks so much for your help!
Merry Christmas and a Happy New Year to you!

Sign in to comment.

More Answers (0)




Translated by