Table: setHeaderVisible(boolean visible) : Table « org.eclipse.swt.widgets « Java by API






Table: setHeaderVisible(boolean visible)


import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

public class MainClass {

  public static void main(String[] a) {
    final Display d = new Display();
    final Shell s = new Shell(d);

    s.setSize(250, 200);
    s.setText("A Table Shell Example");
    s.setLayout(new FillLayout());

    Table t = new Table(s, SWT.BORDER);

    TableColumn tc1 = new TableColumn(t, SWT.CENTER);
    TableColumn tc2 = new TableColumn(t, SWT.CENTER);
    TableColumn tc3 = new TableColumn(t, SWT.CENTER);
    tc1.setText("First Name");
    tc2.setText("Last Name");
    tc3.setText("Address");
    tc1.setWidth(70);
    tc2.setWidth(70);
    tc3.setWidth(80);
    t.setHeaderVisible(true);

    TableItem item1 = new TableItem(t, SWT.NONE);
    item1.setText(new String[] { "A", "B", "Address 1" });
    TableItem item2 = new TableItem(t, SWT.NONE);
    item2.setText(new String[] { "C", "D", "Address 2" });
    TableItem item3 = new TableItem(t, SWT.NONE);
    item3.setText(new String[] { "E", "F", "Address 3" });

    s.open();
    while (!s.isDisposed()) {
      if (!d.readAndDispatch())
        d.sleep();
    }
    d.dispose();
  }
}

           
       








Related examples in the same category

1.new Table(Composite parent, int style)
2.new Table(s, SWT.BORDER | SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION)
3.Table: addListener(int type, Listener lis)
4.Table: getColumnCount()
5.Table: getItem(Point p)
6.Table: setLinesVisible(boolean vi)