Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 285
A S Avatar asked Nov 22 '11 10:11

A S


People also ask

How do you program a button in Matlab?

btn = uibutton creates a push button in a new figure and returns the Button object. MATLAB® calls the uifigure function to create the figure. btn = uibutton( style ) creates a button of the specified style. btn = uibutton( parent ) creates the button in the specified parent container.

What is an alignment button?

To align text using the alignment buttons:Left-align text: Word's default lines up objects to the left with a ragged right edge. Center text: This centers selected text, numbers, and inline objects. Right-align text: Selected text, numbers, and inline objects are aligned to the right with a ragged left edge.

How do you right align text in Matlab?

newStr = strjust( str ) returns a right-justified version of the text in str .


1 Answers

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

like image 189
Amro Avatar answered Sep 27 '22 23:09

Amro