Search code examples
user-interfacematlabbuttonalignmentmatlab-guide

How to align text to the top of the button in Matlab GUI?


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...


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