Werner
Werner

Reputation: 2557

How to create MATLAB static text with editable font style

MATLAB® provides a static text uicontrol (created by using the uicontrol with style text: uicontrol('Style','text','Label','static text'…), which does not allows you to use neither html nor tex interpretation. What is your solution for creating static text interpretable with some language which allows you to change the font style and color?

Upvotes: 0

Views: 3594

Answers (2)

Werner
Werner

Reputation: 2557

My approach works creating a pushbutton and editing its java object so that it looks like a static link. Probably there are other solutions, fill free to improve the topic if you want to do so.

In order to do so, you will need findjobj at Matlab FEX.

Then get the java component from your uicontrol handle, and remove its Border:

pushButtonH=uicontrol('Style','pushbutton','Label','<html>static text',…)
jPushButton = findjobj(pushButtonH);
jPushButton.setBorderPainted(false);

An example using the label as: <html><i><font color="red"> GUI example:

Static Text with color

Upvotes: 0

Luis Mendo
Luis Mendo

Reputation: 112689

Huh? Have you tried this?

h =  uicontrol('Style','text','String','hello');
set(h,'Foregroundcolor','r','FontSize',10,'Fontname','Helvetica','Fontweight','bold');

Is this what you want? Or am I missing something?

Upvotes: 1

Related Questions