Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6528871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:34:32+00:00 2026-05-25T09:34:32+00:00

I have a SWT table which wrapped by the JFace TableViewer, but this problem

  • 0

I have a SWT table which wrapped by the JFace TableViewer, but this problem also applies to org.eclipse.swt.widgets.Table.

When I use a StyledCellLabelProvider, the text is always left aligned, even when I use

colA.getColumn().setAlignment(SWT.RIGHT);

Here is the label provider and setup:

TableViewerColumn colA = new TableViewerColumn(measureTable, SWT.NONE);
colA.setLabelProvider(new StyledCellLabelProvider() {
    @Override
    public void update(ViewerCell cell) {
        ModelItem item = (ModelItem) cell.getElement();
        cell.setFont(FONT_REGISTRY.get(MY_SPECIAL_FONT));
        cell.setText(item.getText());
        super.update(cell);
    }
});

Any sort of workaround would be great. For e.g, nesting a widget inside the table and right aligning the text in the widget somehow.

Platform: Windows 7

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:34:32+00:00Added an answer on May 25, 2026 at 9:34 am

    You found a bug in StyledCellLabelProvider. It will not occur with any other CellLabelProvider.

    StyledCellLabelProvider uses “owner draw” for drawing the Table cells. That means, the cell content is not drawn natively by the OS. It is drawn in an SWT.PaintItem event by the Table “owner”.

    StyledCellLabelProvider does not respect the alignment of the TableColumn. You can see the source here, the method getTextLayoutForInfo(.) is of interest.

    A workaround could be to copy that class, fix the bug by adding

    TableColumn col = ((Table)viewer.getControl()).getColumn(cell.getColumnIndex());
    layout.setAlignment(col.getAlignment());
    

    in the method getTextLayoutForInfo(.) (I didn’t test this fix, but if it doesn’t work, you should get the idea, and be able to make it work)

    You should also add a bug report: Eclipse Bugzilla

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a Table [org.eclipse.swt.widgets.Table] with several TableColumns; however, due to UI space
I have an SWT TableViewer which, of course, displays the contents of a Table
I have the following code generated by Eclipse (.java file). import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Display;
I have a number of tables in an eclipse SWT application. They are Table/TableViewer
My question is that I have a SWT Table in Eclipse RCP project. I
I have an eclipse plugin project which uses some swt objects, eg - import
I have populated swt Table and it displays it OK, but now I want
I have Table which has SWT.CHECK style so I can remove checked items. I
I am writing jython application with eclipse SWT/JFace. I have to pass float array
I have a tiny (rikiki) problem in SWT ... I am making a small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.