0

I have created a table using table viewer, with SWT Java. Now I want to add a button at the end of each row and also in the table column header.Could any one help me how to implement this?

This is how I have started:

this.viewer = new TableViewer(this);
this.table = this.viewer.getTable();
TableColumn column = new TableColumn(this.table, SWT.LEFT);
column.setText("Table Header");
this.table.setHeaderVisible(true);
this.table.setLinesVisible(true);
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Lisha
  • 49
  • 9
  • 1
    You want to add a button to the header? What would that look like? – Baz Jan 11 '17 at 12:01
  • 1
    The table column header does not support buttons. – greg-449 Jan 11 '17 at 12:31
  • yes, to the header ... we have a dialog that has to pop up when we click on that button at the header level. And also each row cell on click of button , it should open other dialog – Lisha Jan 11 '17 at 12:40
  • 1
    @Lisha You could just listen to click events on the header and then show the pop up. – Baz Jan 11 '17 at 12:43
  • @greg-449 : Okay . can we at least add buttons to the each row – Lisha Jan 11 '17 at 17:27
  • @Baz Thank you , I shall try this – Lisha Jan 11 '17 at 17:32
  • @greg-449 or Can we add images instead of button and add listeners for the same ? – Lisha Jan 11 '17 at 18:03
  • @Baz I tried implementing that, but it pops up when i click on table rows,instead i want pop up when clicked on the column header.Could you please help? – Lisha Jan 12 '17 at 04:18
  • @Lisha without seeing your code? Unlikely. – Baz Jan 12 '17 at 07:31
  • @Baz Could you please let me know if i can add buttons in each row ? – Lisha Jan 12 '17 at 09:01
  • @Lisha There's loads of information about this [here](http://stackoverflow.com/questions/12480402/swt-tableviewer-adding-a-remove-button-to-a-column-in-the-table), [here](http://alexander.lds.lg.ua/2010/11/add-swt-widgets-to-the-cells-of-the-table/) and [here](http://sahits.ch/blog/blog/2008/11/04/remove-button-to-remove-itself/). – Baz Jan 12 '17 at 09:09

0 Answers0