Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] RE: platform-swt-dev digest, Vol 1 #802 - 2 msgs

What you are seeing is the native look of a Windows table.  However, here 
is a way to work around it using a ScrolledComposite:

public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        ScrolledComposite sc = new ScrolledComposite(shell, SWT.V_SCROLL 
|SWT.H_SCROLL);
        final Table table = new Table(sc, SWT.FULL_SELECTION);
        table.setLinesVisible(true);
        final TableColumn column1 = new TableColumn(table, SWT.NONE);
        final TableColumn column2 = new TableColumn(table, SWT.NONE);
        for (int i = 0; i < 5; i++) {
                TableItem item = new TableItem(table, SWT.NONE);
                item.setText(new String[] {"item " + i, "asd asdads 
dsadsdsadsad"});
        }
        column1.pack();
        column2.pack();
        sc.setContent(table);
        sc.setBackground(table.getBackground());
        Point size = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        Point vSize = table.getVerticalBar().getSize();
        Point hSize = table.getHorizontalBar().getSize();
        table.setSize(size.x - vSize.x, size.y - hSize.y);
 
        Button b = new Button(shell, SWT.PUSH);
        b.setText("Insert row");
        b.addListener(SWT.Selection, new Listener(){
                public void handleEvent(Event event) {
                        TableItem item = new TableItem(table, SWT.NONE);
                        item.setText(new String[] {"New Item", "inserted 
here"});
                        column1.pack();
                        column2.pack();
                        Point size = table.computeSize(SWT.DEFAULT, 
SWT.DEFAULT);
                        Point vSize = table.getVerticalBar().getSize();
                        Point hSize = table.getHorizontalBar().getSize();
                        table.setSize(size.x - vSize.x, size.y - hSize.y);
                }
        });
        shell.open();
        while (!shell.isDisposed()) {
                if (!display.readAndDispatch())
                        display.sleep();
        }
        display.dispose();
}




"Anil Kumar" <anilkumar.d@xxxxxxxxxxxx> 
Sent by: platform-swt-dev-admin@xxxxxxxxxxx
12/21/2003 04:33 AM
Please respond to
platform-swt-dev


To
<platform-swt-dev@xxxxxxxxxxx>
cc

Subject
[platform-swt-dev] RE: platform-swt-dev digest, Vol 1 #802 - 2 msgs






hello swt,

i am using a SWT Table. Even if there is no single row added to table it 
is
showing lines look like rows in a table. and also one additional column.
when i add rows to the tabel clicking on the add button on the screen, 
when
enough row added to fit in the table height the empty rows are not there.
when i delete rows from the table again empty lines are coming. Can any 
one
help me how to avoid this unnecessary look and feel of rows in a table. As
we are migrating a swing product to SWT.

i have used setSize() of TableColumn. but when i resize the screen the 
table
area also expands again shows the second column.

Thank you very much in advance for solution to this problems.

regards
Anil Kumar

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev




Back to the top