Skip to main content



      Home
Home » Newcomers » Newcomers » Extra space in the Table of Swt
Extra space in the Table of Swt [message #194620] Fri, 16 February 2007 08:38 Go to next message
Eclipse UserFriend
Hi All,

I am creating a table in the SWT. But i am getting a small extra column at
the end of my Table...

Is there any way to overcome this....

Regards,

Zakir
Re: Extra space in the Table of Swt [message #194649 is a reply to message #194620] Fri, 16 February 2007 10:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wayne.beaton._NOSPAM_eclipse.org

You may get a different/better answer by posting this question on
eclipse.platform.swt.

My guess is that the small extra column is the left over space after
you've created the columns you care about. You probably specified widths
on each of the columns, and all the widths of the columns don't add up
to the width of the table.

If you care (i.e. if you want the columns to consume the full width of
the table and no more), you should be able to set up a resize listener
that adjusts the widths of the columns when the table is resized.

HTH,

Wayne

zakir wrote:
> Hi All,
>
> I am creating a table in the SWT. But i am getting a small extra column
> at the end of my Table...
>
> Is there any way to overcome this....
>
> Regards,
>
> Zakir
>
Re: Extra space in the Table of Swt [message #194674 is a reply to message #194649] Fri, 16 February 2007 13:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi wayne,

I have tried changing in...plugin.xml

I had also tried by changing the product file....

But this is not working.....

Is there any alternate way to perform this task....


Thanks in advance....

Regards,

Zakir
Re: Extra space in the Table of Swt [message #194706 is a reply to message #194674] Fri, 16 February 2007 14:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wayne.beaton._NOSPAM_eclipse.org

zakir wrote:
> Hi wayne,
>
> I have tried changing in...plugin.xml
>
> I had also tried by changing the product file....
>
> But this is not working.....

What are you trying to change?
Re: Extra space in the Table of Swt [message #194714 is a reply to message #194649] Fri, 16 February 2007 14:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wayne.beaton._NOSPAM_eclipse.org

For kicks, I decided to do a quick implementation of a table that
automatically resizes it's columns to fill the available space. You can
easily adapt this to weight columns to make them consume some portion of
the available space.

I turned off the resize ability (i.e. the user can't resize) but you can
accommodate for this as well, if desired.

The example is based on SWT snippet #38

More snippets at: http://www.eclipse.org/swt/snippets/

/*********************************************************** ********************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation

************************************************************ *******************/
package org.eclipse.swt.snippets;

/*
* Table example snippet: create a table (columns, headers, lines)
*
* For a list of all SWT example snippets see
* http://www.eclipse.org/swt/snippets/
*/
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
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 Snippet38 {

public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
final Table table = new Table (shell, SWT.MULTI | SWT.BORDER |
SWT.FULL_SELECTION);
table.setLinesVisible (true);
table.setHeaderVisible (true);
String[] titles = {"Column1", "Column2", "Column3"};
for (int i=0; i<titles.length; i++) {
TableColumn column = new TableColumn (table, SWT.NONE);
column.setResizable(false);
column.setText (titles [i]);
}
int count = 128;
for (int i=0; i<count; i++) {
TableItem item = new TableItem (table, SWT.NONE);
item.setText (0, "x");
item.setText (1, "y");
item.setText (2, "z");
}
//table.setSize (table.computeSize (SWT.DEFAULT, 200));
//shell.pack ();
table.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
TableColumn[] columns = table.getColumns();
int columnWidth = table.getClientArea().width /
columns.length;
for(int index=0;index<columns.length;index++)
columns[index].setWidth(columnWidth);
}
});
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
Re: Extra space in the Table of Swt [message #194744 is a reply to message #194714] Sat, 17 February 2007 00:11 Go to previous message
Eclipse UserFriend
Thanks Wayne,

My problem is resolved...

I was answering another question and by mistake i had writeen the comment
for that question to you... sorry for my previous message...


Thanks again for you suggestion...

Regards,

Zakir
Previous Topic:"Impossible to resolve dependencies" error
Next Topic:Updating the About Text of RCP
Goto Forum:
  


Current Time: Mon May 12 16:37:52 EDT 2025

Powered by FUDForum. Page generated in 0.09274 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top