UIComponent JTextField Text alignment

2 ビュー (過去 30 日間)
Michael Critchfield
Michael Critchfield 2018 年 11 月 27 日
コメント済み: Michael Critchfield 2018 年 12 月 26 日
Hi,
I included Yair Altman's UICOMPONENT to place a Text Field on my figure like so:
myFigure=figure('position',[200,200,350,200]);
JTextField=uicomponent('Parent',myFigure,'style','JTextField',...
'position',[100,100,150,20],'Text','TestText','KeyTypedCallback',@testCallb);
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 件のコメント
Michael Critchfield
Michael Critchfield 2018 年 11 月 29 日
Hello,
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:
set(ProjectNameEdit,'HorizontalAlignment','RIGHT');
%Error: Parameter must be scalar.
I also tried 1 and true
Can someone please help me with this?

サインインしてコメントする。

採用された回答

Yair Altman
Yair Altman 2018 年 12 月 25 日
Use JTextField.JavaPeer.CENTER or the value 0 instead of 'CENTER':
JTextField.HorizontalAlignment = JTextField.JavaPeer.CENTER; % =0
  1 件のコメント
Michael Critchfield
Michael Critchfield 2018 年 12 月 26 日
Thanks so much for your help!
Merry Christmas and a Happy New Year to you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by