0

I am learning to work with SWT. I added two Tables to one Composite using:

    TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
    tabFolder.setLayoutData(BorderLayout.CENTER);

    TabItem tbtmData = new TabItem(tabFolder, SWT.NONE);
    tbtmData.setText("data");

    scrolledComposite = new ScrolledComposite(tabFolder, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    tbtmData.setControl(scrolledComposite);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);

    tableComposite = new Composite(scrolledComposite, SWT.NONE);
    RowLayout rl_tableComposite = new RowLayout(SWT.HORIZONTAL);
    tableComposite.setLayout(rl_tableComposite);

    table_2 = new Table(tableComposite, SWT.BORDER | SWT.FULL_SELECTION);
    table_2.setHeaderVisible(true);
    table_2.setLinesVisible(true);

    table_3 = new Table(tableComposite, SWT.BORDER | SWT.FULL_SELECTION);
    table_3.setLayoutData(new RowData(261, 45));
    table_3.setTopIndex(1);
    table_3.setHeaderVisible(true);
    table_3.setLinesVisible(true);



    scrolledComposite.setContent(tableComposite);
    scrolledComposite.setMinSize(tableComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    TabItem tbtmGraph = new TabItem(tabFolder, SWT.NONE);
    tbtmGraph.setText("graph");

    Canvas canvas = new Canvas(tabFolder, SWT.NONE);
    tbtmGraph.setControl(canvas);

Now, in the window I see table_2 in the left and table_3 in the right. How to change the order in a runtime? Adding table_3 first is not an option in my case.

One more question. if i call table.setSize(0, 0); I don't see any changes in table appearance. I tried to call table.redraw() after that, but still, size of the table is not changing. where is my mistake?

PauliusM
  • 171
  • 1
  • 11

1 Answers1

2

You can call:

tableThree.moveAbove(tableTwo);

See the javadoc for more detail.

As for your second question:

Why do you want to set the size to 0? Doesn't Control#setVisible(false) do the trick?

Baz
  • 36,440
  • 11
  • 68
  • 94
  • yes, `tableThree.moveAbove(tableTwo)` works fine. I want to set table size to zero, so other controls could occupy the space that was previous occupied by the table. Its not happening when I try to use `setVisible(false)` – PauliusM May 07 '14 at 11:11
  • @PauliusM This question has already been answered [here](http://stackoverflow.com/a/17513270/1740724). In addition, you can simply `dispose()` the `Table` if you don't need it anymore. – Baz May 07 '14 at 11:16
  • I manage to achieve desirable behaviour of the `table`'s by using code in the link you provided. Thank you for your help! – PauliusM May 07 '14 at 12:53
  • @PauliusM No problem, alsways glad if I can help :) – Baz May 07 '14 at 12:55