Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Table do not display horizontal scrollbar
icon5.gif  Table do not display horizontal scrollbar [message #1703367] Fri, 31 July 2015 03:23
Eclipse UserFriend
Hi all,

I'm quite new in the RCP development, but I can already do a lot of stuff, the framework is intuitive and there are a lot of tuto on the net.

However, I'm stuck with a table problem... I have tables in several views and it's the same for all tables! I cannot have a horizontal scrollbar.

I though the problem was coming my own implementation so I just tried with the tuto example code from vogella EclipseJFaceTable and same problem...

public void createPartControl(Composite parent) {
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    createColumns(parent, viewer);
    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    viewer.setContentProvider(new ArrayContentProvider());
    // get the content for the viewer, setInput will call getElements in the
    // contentProvider
    viewer.setInput(ModelProvider.INSTANCE.getPersons());
    // make the selection available to other views
    getSite().setSelectionProvider(viewer);
    // set the sorter for the table

    // define layout for the viewer
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.horizontalSpan = 2;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    viewer.getControl().setLayoutData(gridData);
  }

  // create the columns for the table
  private void createColumns(final Composite parent, final TableViewer viewer) {
    String[] titles = { "First name", "Last name", "Gender", "Married" };
    int[] bounds = { 100, 100, 100, 100 };

    // first column is for the first name
    TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0);
    col.setLabelProvider(new ColumnLabelProvider() {
      @Override
      public String getText(Object element) {
        Person p = (Person) element;
        return p.getFirstName();
      }
    });

    // second column is for the last name
    col = createTableViewerColumn(titles[1], bounds[1], 1);
    col.setLabelProvider(new ColumnLabelProvider() {
      @Override
      public String getText(Object element) {
        Person p = (Person) element;
        return p.getLastName();
      }
    });

    // now the gender
    col = createTableViewerColumn(titles[2], bounds[2], 2);
    col.setLabelProvider(new ColumnLabelProvider() {
      @Override
      public String getText(Object element) {
        Person p = (Person) element;
        return p.getGender();
      }
    });

    // now the status married
    col = createTableViewerColumn(titles[3], bounds[3], 3);
    col.setLabelProvider(new ColumnLabelProvider() {
      @Override
      public String getText(Object element) {
        return ((Person)element).isMarried() + "";
      }
  }

  private TableViewerColumn createTableViewerColumn(String title, int bound, final int colNumber) {
    final TableViewerColumn viewerColumn = new TableViewerColumn(viewer,
        SWT.NONE);
    final TableColumn column = viewerColumn.getColumn();
    column.setText(title);
    column.setWidth(bound);
    column.setResizable(true);
    column.setMoveable(true);
    return viewerColumn;
  }



Columns will not increase the table width... Event with the pack method call, last columns will have a width of 0.... (see joined image (right table))


I searched on the net without any solutions...

If I change the view height, the vertical scrollbar appears/hides as expected, but impossible to have the same behaviour with the horizontal one... changing the view width, will just increase/decrease column width, but no horizontal scrollbar is available...

What is the problem? the problem cause?

please, help ^^
Previous Topic:ascending descending table column in swt
Next Topic:Nested table view in Tree or Table Viewer
Goto Forum:
  


Current Time: Sun Aug 31 00:08:31 EDT 2025

Powered by FUDForum. Page generated in 0.02859 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top