Results 1 to 2 of 2
  1. #1
    feiqu0325 is offline Member
    Join Date
    Feb 2009
    Posts
    1
    Rep Power
    0

    Default Can't add columns in table viewer

    Hi, I want to create a table viewer with some columns. I created a table viewer by swt designer. Then I added columns and column names by code. However, I couldn't find those columns in design mode and run time. Following is my source (including code generated by swt designer). Please help me to fix this problem. Thanks!
    final TableViewer tableViewer = new TableViewer(shell, SWT.BORDER);
    final Table table = tableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.setBounds(32, 28, 400, 100);
    TableLayout layout = new TableLayout();
    table.setLayout(layout);
    layout.addColumnData(new ColumnWeightData(50));
    new TableColumn(table, SWT.NONE).setText("Flight ID");
    layout.addColumnData(new ColumnWeightData(50));
    new TableColumn(table, SWT.NONE).setText("Airplane ID");
    layout.addColumnData(new ColumnWeightData(50));
    new TableColumn(table, SWT.NONE).setText("Seat number");
    layout.addColumnData(new ColumnWeightData(50));
    new TableColumn(table, SWT.NONE).setText("Airplane type");
    layout.addColumnData(new ColumnWeightData(50));
    new TableColumn(table, SWT.NONE).setText("Departure date");
    layout.addColumnData(new ColumnWeightData(50));
    new TableColumn(table, SWT.NONE).setText("Departure location");
    layout.addColumnData(new ColumnWeightData(50));
    new TableColumn(table, SWT.NONE).setText("Destination");
    layout.addColumnData(new ColumnWeightData(50));
    new TableColumn(table, SWT.NONE).setText("Cost");

  2. #2
    trax is offline Member
    Join Date
    Mar 2009
    Posts
    42
    Rep Power
    0

    Default

    final TableViewer tableViewer = new TableViewer(shell, SWT.BORDER);
    final Table table = tableViewer.getTable();

    TableLayout layout = new TableLayout();
    table.setLayout(layout);



    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setWidth(200);
    column.setText("Flight Id");

    column = new TableColumn(table, SWT.NONE);
    column.setWidth(200);
    column.setText("Airplane Id");

    column = new TableColumn(table, SWT.NONE);
    column.setWidth(200);
    column.setText("Airplane Type");



    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.setBounds(32, 28, 400, 100);


    Use this code n it will show columns.
    Regards,
    vinay

Similar Threads

  1. Jface Viewer help
    By JohnTayler in forum SWT / JFace
    Replies: 2
    Last Post: 04-22-2009, 11:28 PM
  2. Replies: 0
    Last Post: 07-11-2008, 03:08 PM
  3. Annotation Viewer
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:01 PM
  4. Getting names of table columns
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-07-2008, 08:39 AM
  5. iSQL-Viewer 3.0.0
    By levent in forum Java Software
    Replies: 0
    Last Post: 06-04-2007, 08:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •