Table with ScrollBars and SetSize. [message #122954] |
Fri, 05 September 2003 09:03  |
Eclipse User |
|
|
|
Originally posted by: pkumar.louveciennes.sema.slb.com
hello
I am trying to create a table . But I am unable to set it's size.to be
more precise, the size changes according to the no of elements. But my
requirement is to show only 10 elements in table with scroll bars. I
tried variuos methods but , no effects.
I tried to use the redraw methos which sets the size with scrollbars ,
but nothing appears in the table.
please find attached the method where I am creating table.
thanks
Prameela
----------------------code ---------------------------------------
public void someMethod
{
..................
.............
Rectangle rect = Display.getCurrent().getClientArea();
System.out.println("Rectangle "+ rect.height+" width "+rect.width);
//create Table group
tabItem1 = new TabItem(tabFolder, SWT.NONE);
Group tableGroup = new Group(tabFolder, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
tableGroup.setLayout(layout);
GridData gd = new GridData(GridData.FILL);
tableGroup.setLayoutData(gd);
gd.widthHint = rect.width - tabFolder.getSize().x;
gd.heightHint = rect.height - tabFolder.getSize().y / 2;
//create table
classTable = new Table(tableGroup, SWT.V_SCROLL | SWT.H_SCROLL |
SWT.CHECK);
classTable.setLinesVisible(true);
classTable.setHeaderVisible(true);
gd = new GridData(GridData.FILL_VERTICAL);
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalIndent = 10;
classTable.setLayoutData(gd);
classTable.setBackground(tableBGColor);
//create columns
/* Fill the table with data */
for (int i = 0; i < columnTitles.length; i++)
{
TableColumn tableColumn = new
TableColumn(classTable, SWT.NONE);
tableColumn.setAlignment(SWT.CENTER);
tableColumn.setWidth(51);
tableColumn.setText(columnTitles[i]);
tableColumn.setResizable(true);
}
//create Items
for (int j = 0; j < 15; j++)
{
TableItem tableItem1 = new TableItem(classTable, SWT.NONE);
tableItem1.setText(data);
}
for (int i = 0; i < classTable.getColumnCount(); i++)
{
TableColumn tableColumn = classTable.getColumn(i);
tableColumn.pack();
}
//classTable.setRedraw(false);
classTable.pack();
tabItem1.setControl(tableGroup);
tabItem1.setText("Applets");
}
|
|
|
Re: Table with ScrollBars and SetSize. [message #122957 is a reply to message #122954] |
Fri, 05 September 2003 09:29  |
Eclipse User |
|
|
|
Prameela schrieb:
> hello
>
> I am trying to create a table . But I am unable to set it's size.to be
> more precise, the size changes according to the no of elements. But my
> requirement is to show only 10 elements in table with scroll bars. I
> tried variuos methods but , no effects.
> I tried to use the redraw methos which sets the size with scrollbars ,
> but nothing appears in the table.
> please find attached the method where I am creating table.
>
> thanks
> Prameela
Hi Prameela,
don't pack your table. If you pack it it will be resized and that is
what you want to avoid. Set the size of your table explicitely.
Ralf
> ----------------------code ---------------------------------------
>
>
> public void someMethod
> {
> .................
> ............
>
> Rectangle rect = Display.getCurrent().getClientArea();
> System.out.println("Rectangle "+ rect.height+" width "+rect.width);
>
> //create Table group
> tabItem1 = new TabItem(tabFolder, SWT.NONE);
> Group tableGroup = new Group(tabFolder, SWT.NONE);
> GridLayout layout = new GridLayout();
> layout.numColumns = 2;
> tableGroup.setLayout(layout);
> GridData gd = new GridData(GridData.FILL);
> tableGroup.setLayoutData(gd);
> gd.widthHint = rect.width - tabFolder.getSize().x;
> gd.heightHint = rect.height - tabFolder.getSize().y / 2;
>
> //create table
> classTable = new Table(tableGroup, SWT.V_SCROLL | SWT.H_SCROLL |
> SWT.CHECK);
> classTable.setLinesVisible(true);
> classTable.setHeaderVisible(true);
> gd = new GridData(GridData.FILL_VERTICAL);
> gd.horizontalSpan = 2;
> gd.grabExcessHorizontalSpace = true;
> gd.grabExcessVerticalSpace = true;
> gd.horizontalIndent = 10;
> classTable.setLayoutData(gd);
> classTable.setBackground(tableBGColor);
>
> //create columns
> /* Fill the table with data */
> for (int i = 0; i < columnTitles.length; i++)
> {
> TableColumn tableColumn = new TableColumn(classTable,
> SWT.NONE);
> tableColumn.setAlignment(SWT.CENTER);
> tableColumn.setWidth(51);
> tableColumn.setText(columnTitles[i]);
> tableColumn.setResizable(true);
>
> }
> //create Items
> for (int j = 0; j < 15; j++)
> {
> TableItem tableItem1 = new TableItem(classTable, SWT.NONE);
> tableItem1.setText(data);
>
> }
>
> for (int i = 0; i < classTable.getColumnCount(); i++)
> {
>
> TableColumn tableColumn = classTable.getColumn(i);
> tableColumn.pack();
> }
> //classTable.setRedraw(false);
> classTable.pack();
> tabItem1.setControl(tableGroup);
> tabItem1.setText("Applets");
> }
>
|
|
|
Powered by
FUDForum. Page generated in 0.03637 seconds