1

I am looking to have all of the strings in a popupmenu centered in the menu. Now they are all left aligned and it just looks a little off.

Is there any way to do this easily?

Suever
  • 64,497
  • 14
  • 82
  • 101
Jtt3mr
  • 25
  • 4

1 Answers1

1

You can do this via the java handle to the uicontrol. You can get the java handle using Yair's findjobj utility from the file exchange.

p = uicontrol('style', 'popupmenu', 'String', {'item1', 'item2'}, 'Position', [0 0 200 30]);
jobj = findjobj(p);

renderer = jobj.getRenderer();
renderer.setHorizontalAlignment(renderer.CENTER);

enter image description here

Suever
  • 64,497
  • 14
  • 82
  • 101