Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Table doesn't render right on Mac OS X
Table doesn't render right on Mac OS X [message #460663] Fri, 02 September 2005 20:05 Go to next message
Mike Yawn is currently offline Mike YawnFriend
Messages: 50
Registered: July 2009
Member
I'm having two problems when trying to display a table on Mac OS X:

- grid lines are never visible (setLinesVisible(true) has no effect
- the table is much wider than needed (about double) -- calling pack() or
setSize(computeSize()) has no effect.

The same code, when run on a Windows box, behaves as expected.

Running Mac OS 10.4.2, Eclipse 3.1.

Are there known gotchas in table rendering between OS X and Windows?
Anything I can add to the code below to make it display consistently
across both (preferably all) platforms?

Thanks,
Mike

Sample code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
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 MacExample {

public static void main(String[] args) {

Display display = new Display();
GridLayout layout = new GridLayout();
layout.numColumns =1;
Shell shell = new Shell(display);
shell.setLayout(layout);

Table grid = new Table(shell, SWT.SINGLE);
grid.setLinesVisible(true);

int columns = 4;
int rows = 10;


for (int i = 0; i < columns; i++) {
TableColumn tc2 = new TableColumn(grid, SWT.CENTER);
tc2.setWidth(10);
tc2.pack();
}


TableItem[] items = new TableItem[rows];
for (int i = 0; i < rows; i++) {
TableItem item = new TableItem(grid, SWT.NONE);
item.setText(new String[] {"1", "2", "3", "4"});
items[i] = item;
}

for (int i=0; i<columns; i++) {
TableColumn tc = grid.getColumn(i);
tc.pack();
}
grid.pack();
grid.setSize(grid.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
shell.pack();

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}

}
Re: Table doesn't render right on Mac OS X [message #460721 is a reply to message #460663] Mon, 05 September 2005 13:53 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
They could well be bugs in the Mac OS X implementation of SWT. It would be good to report any headaches that you are having at http://bugs.eclipse.org (with code samples, if you've got them) and screenshots of other Mac OS X applications to show what you'd expect it to look like.

If you do a search for 'mac swt table' you can see what bugs are currently reported, and if yours isn't mentioned, then please submit the bug report.
Re: Table doesn't render right on Mac OS X [message #460765 is a reply to message #460663] Wed, 07 September 2005 00:59 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Try again using the latest code from HEAD. Both problems should be fixed.
If you are running Tiger, then grid lines are supported (otherwise, they are
not supported because the operating system had no such concept). The
computeSize() bugs should also be fixed.

"Mike Yawn" <mike@theYawns.com> wrote in message
news:23d67c8856eba91a12e7c4108b5e8ea9$1@www.eclipse.org...
> I'm having two problems when trying to display a table on Mac OS X:
>
> - grid lines are never visible (setLinesVisible(true) has no effect
> - the table is much wider than needed (about double) -- calling pack() or
> setSize(computeSize()) has no effect.
>
> The same code, when run on a Windows box, behaves as expected.
>
> Running Mac OS 10.4.2, Eclipse 3.1.
>
> Are there known gotchas in table rendering between OS X and Windows?
> Anything I can add to the code below to make it display consistently
> across both (preferably all) platforms?
>
> Thanks,
> Mike
>
> Sample code:
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.GridLayout;
> 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 MacExample {
>
> public static void main(String[] args) {
>
> Display display = new Display();
> GridLayout layout = new GridLayout();
> layout.numColumns =1;
> Shell shell = new Shell(display);
> shell.setLayout(layout);
>
> Table grid = new Table(shell, SWT.SINGLE);
> grid.setLinesVisible(true);
>
> int columns = 4;
> int rows = 10;
>
>
> for (int i = 0; i < columns; i++) {
> TableColumn tc2 = new TableColumn(grid, SWT.CENTER);
> tc2.setWidth(10);
> tc2.pack();
> }
>
>
> TableItem[] items = new TableItem[rows];
> for (int i = 0; i < rows; i++) {
> TableItem item = new TableItem(grid, SWT.NONE);
> item.setText(new String[] {"1", "2", "3", "4"});
> items[i] = item;
> }
>
> for (int i=0; i<columns; i++) {
> TableColumn tc = grid.getColumn(i);
> tc.pack();
> }
> grid.pack();
> grid.setSize(grid.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
> shell.pack();
>
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
>
> }
>
Previous Topic:fun with fonts
Next Topic:Combo - Showing list on focus
Goto Forum:
  


Current Time: Thu Jun 27 00:39:15 GMT 2019

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

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

Back to the top