Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
uitable: align text to right

Subject: uitable: align text to right

From: ventus85

Date: 13 Feb, 2009 08:45:05

Message: 1 of 4

The number of the line is attached to data,
I would like to align text on the right in the uitable.

Thank you.

Subject: uitable: align text to right

From: Dave Brackett

Date: 13 Feb, 2009 10:14:02

Message: 2 of 4

"ventus85 " <ventus85@katamail.com> wrote in message <gn3buh$dd9$1@fred.mathworks.com>...
> The number of the line is attached to data,
> I would like to align text on the right in the uitable.
>
> Thank you.


based on this previous post it doesn't appear to be possible to right align text in the table: http://www.mathworks.ch/matlabcentral/newsreader/view_thread/169421

Subject: uitable: align text to right

From: Yair Altman

Date: 15 Feb, 2009 13:36:01

Message: 3 of 4

"Dave Brackett" <davebrackett@hotmail.com> wrote in message <gn3h5a$7cl$1@fred.mathworks.com>...
> "ventus85 " <ventus85@katamail.com> wrote in message <gn3buh$dd9$1@fred.mathworks.com>...
> > The number of the line is attached to data,
> > I would like to align text on the right in the uitable.
> >
> > Thank you.
>
>
> based on this previous post it doesn't appear to be possible to right align text in the table: http://www.mathworks.ch/matlabcentral/newsreader/view_thread/169421

it can be done if you set a new TableCellRenderer, as explained here: http://forums.sun.com/thread.jspa?threadID=560517&tstart=88

renderer = javax.swing.table.DefaultTableCellRenderer;
renderer.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jtable.getColumnModel.getColumn(1).setCellRenderer(renderer);

unfortunately, this works only if you use a standard JTable or Matlab's deprecated version of uitable; Matlab's new built-in uitable (actually, JideSoft's tables which Matlab uses) apparently doesn't enable modifying its CellRenderers...

Yair altman

Subject: uitable: align text to right

From: ventus85

Date: 15 Feb, 2009 20:11:02

Message: 4 of 4

Thank you for all the answers.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us