Question

I have a GUI with big buttons and wouls like to align the text in the button to the top, all I found is "horizontal alignment" property. Thanks...

Was it helpful?

Solution

You need to access the underlying Java Swing component (I am using FINDJOBJ function):

figure('Menubar','none', 'Position',[200 200 300 200])
h = uicontrol('Style','pushbutton', 'String','click', ...
   'Units','normalized', 'Position',[0.3 0.3 0.5 0.5]);
jh = findjobj(h);
jh.setVerticalAlignment( javax.swing.AbstractButton.BOTTOM );

enter image description here

OTHER TIPS

I'm afraid I think you can't do this - text is always vertically aligned at the middle on a uicontrol. The only hacks I can think of that might achieve something like what you want are

  1. Add extra return characters after your main text, so that the real text ends up at the top while the whole text remains centred
  2. (REALLY horrible) Create an image with your text right at the top, and use this with the CData property of the button.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top