Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT Problems on Linux
SWT Problems on Linux [message #441701] Fri, 20 August 2004 16:31 Go to next message
Mike Simpson is currently offline Mike SimpsonFriend
Messages: 1
Registered: July 2009
Junior Member
Hi,
I'm new to SWT and am having a couple of minor problems. I'm writing a
pretty simple app with menu, tab folder, and a couple of tables in one of
the tabs.

The app works perfectly on Windows, but when I run it under Linux, I have
two problems: first, my menu doesn't show up until I resize the shell.
Second, setting the initial widths of the table columns seems to have no
effect.

On this second issue, I wrote a custom "layout manager" (TableLayout) to
control the widths of the columns, but when I trace through it I notice
that even after creating the columns and setting the widths, getWidth()
still returns 0. This occurs before my layout manager is even created, so
I don't think it's the problem.

Here's the code that sets up the GUI (some objects declared in advance):

display = new Display();
Display.setAppName("JuMP3");

// Create and set up shell
shell = new Shell(display);
shell.setText("JuMP3");
shell.setSize(600, 450);

shell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
quit();
}
});

// Create menu bar
menu = new Menu(shell, SWT.BAR);
shell.setMenuBar(menu);

// Create file menu
MenuItem fileMenuItem = new MenuItem(menu, SWT.CASCADE);
fileMenuItem.setText("&File");

Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
fileMenuItem.setMenu(fileMenu);

new MenuItem(fileMenu, SWT.SEPARATOR);

MenuItem fileExitMenuItem = new MenuItem(fileMenu, SWT.PUSH);
fileExitMenuItem.setText("E&xit");

fileExitMenuItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
quit();
}
});

// Create help menu
MenuItem helpMenuItem = new MenuItem(menu, SWT.CASCADE);
helpMenuItem.setText("&Help");

Menu helpMenu = new Menu(shell, SWT.DROP_DOWN);
helpMenuItem.setMenu(helpMenu);

MenuItem helpAboutMenuItem = new MenuItem(helpMenu, SWT.PUSH);
helpAboutMenuItem.setText("&About...");

// Create layout
FormLayout layout = new FormLayout();
layout.marginHeight = 5;
layout.marginWidth = 5;
shell.setLayout(layout);

// Create tab folder
TabFolder tabFolder = new TabFolder(shell, SWT.NONE);

FormData ld = new FormData();
ld.top = new FormAttachment(0);
ld.bottom = new FormAttachment(100);
ld.left = new FormAttachment(0);
ld.right = new FormAttachment(100);
tabFolder.setLayoutData(ld);

TabItem spTab = new TabItem(tabFolder, SWT.NONE);
spTab.setText("Servers/Players");
Composite spTabControl = new Composite(tabFolder, SWT.NONE);
spTab.setControl(spTabControl);

layout = new FormLayout();
layout.marginHeight = 5;
layout.marginWidth = 5;
spTabControl.setLayout(layout);

TabItem plTab = new TabItem(tabFolder, SWT.NONE);
plTab.setText("Playlists");
Composite plTabControl = new Composite(tabFolder, SWT.NONE);
plTab.setControl(plTabControl);

layout = new FormLayout();
layout.marginHeight = 5;
layout.marginWidth = 5;
plTabControl.setLayout(layout);

// Create label
Label svrLabel = new Label(spTabControl, SWT.NONE);
svrLabel.setText("Servers:");

// Create servers table
svrTable = new Table(spTabControl, SWT.FULL_SELECTION | SWT.BORDER);
svrTable.setHeaderVisible(true);
svrTable.setLinesVisible(true);

ld = new FormData();
ld.left = new FormAttachment(0);
ld.right = new FormAttachment(100);
ld.top = new FormAttachment(svrLabel, 5, SWT.BOTTOM);
ld.bottom = new FormAttachment(plrLabel, -5, SWT.TOP);
svrTable.setLayoutData(ld);

// Create table columns
TableColumn svrTableHosts = new TableColumn(svrTable, SWT.NONE);
svrTableHosts.setText("Name");
svrTableHosts.setWidth(300);

// ----> getWidth() still zero at this point <----

TableColumn svrTableLocs = new TableColumn(svrTable, SWT.NONE);
svrTableLocs.setText("Location");

// Open window
shell.layout();
shell.open();

I'm sure I'm not doing something right :-) Any pointers would be
appreciated - thanks!
Mike
Re: SWT Problems on Linux [message #441752 is a reply to message #441701] Mon, 23 August 2004 18:05 Go to previous messageGo to next message
Silenio Quarti is currently offline Silenio QuartiFriend
Messages: 31
Registered: July 2009
Member
Please open a bug report with this info and add which version and platform
(motif or gtk) of swt are you running.

Silenio


Mike Simpson wrote:

> Hi,
> I'm new to SWT and am having a couple of minor problems. I'm writing a
> pretty simple app with menu, tab folder, and a couple of tables in one of
> the tabs.

> The app works perfectly on Windows, but when I run it under Linux, I have
> two problems: first, my menu doesn't show up until I resize the shell.
> Second, setting the initial widths of the table columns seems to have no
> effect.

> On this second issue, I wrote a custom "layout manager" (TableLayout) to
> control the widths of the columns, but when I trace through it I notice
> that even after creating the columns and setting the widths, getWidth()
> still returns 0. This occurs before my layout manager is even created, so
> I don't think it's the problem.

> Here's the code that sets up the GUI (some objects declared in advance):

> display = new Display();
> Display.setAppName("JuMP3");

> // Create and set up shell
> shell = new Shell(display);
> shell.setText("JuMP3");
> shell.setSize(600, 450);

> shell.addDisposeListener(new DisposeListener() {
> public void widgetDisposed(DisposeEvent e) {
> quit();
> }
> });

> // Create menu bar
> menu = new Menu(shell, SWT.BAR);
> shell.setMenuBar(menu);

> // Create file menu
> MenuItem fileMenuItem = new MenuItem(menu, SWT.CASCADE);
> fileMenuItem.setText("&File");

> Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
> fileMenuItem.setMenu(fileMenu);

> new MenuItem(fileMenu, SWT.SEPARATOR);

> MenuItem fileExitMenuItem = new MenuItem(fileMenu, SWT.PUSH);
> fileExitMenuItem.setText("E&xit");

> fileExitMenuItem.addListener(SWT.Selection, new Listener() {
> public void handleEvent(Event e) {
> quit();
> }
> });

> // Create help menu
> MenuItem helpMenuItem = new MenuItem(menu, SWT.CASCADE);
> helpMenuItem.setText("&Help");

> Menu helpMenu = new Menu(shell, SWT.DROP_DOWN);
> helpMenuItem.setMenu(helpMenu);

> MenuItem helpAboutMenuItem = new MenuItem(helpMenu, SWT.PUSH);
> helpAboutMenuItem.setText("&About...");

> // Create layout
> FormLayout layout = new FormLayout();
> layout.marginHeight = 5;
> layout.marginWidth = 5;
> shell.setLayout(layout);

> // Create tab folder
> TabFolder tabFolder = new TabFolder(shell, SWT.NONE);

> FormData ld = new FormData();
> ld.top = new FormAttachment(0);
> ld.bottom = new FormAttachment(100);
> ld.left = new FormAttachment(0);
> ld.right = new FormAttachment(100);
> tabFolder.setLayoutData(ld);

> TabItem spTab = new TabItem(tabFolder, SWT.NONE);
> spTab.setText("Servers/Players");
> Composite spTabControl = new Composite(tabFolder, SWT.NONE);
> spTab.setControl(spTabControl);

> layout = new FormLayout();
> layout.marginHeight = 5;
> layout.marginWidth = 5;
> spTabControl.setLayout(layout);

> TabItem plTab = new TabItem(tabFolder, SWT.NONE);
> plTab.setText("Playlists");
> Composite plTabControl = new Composite(tabFolder, SWT.NONE);
> plTab.setControl(plTabControl);

> layout = new FormLayout();
> layout.marginHeight = 5;
> layout.marginWidth = 5;
> plTabControl.setLayout(layout);

> // Create label
> Label svrLabel = new Label(spTabControl, SWT.NONE);
> svrLabel.setText("Servers:");

> // Create servers table
> svrTable = new Table(spTabControl, SWT.FULL_SELECTION | SWT.BORDER);
> svrTable.setHeaderVisible(true);
> svrTable.setLinesVisible(true);

> ld = new FormData();
> ld.left = new FormAttachment(0);
> ld.right = new FormAttachment(100);
> ld.top = new FormAttachment(svrLabel, 5, SWT.BOTTOM);
> ld.bottom = new FormAttachment(plrLabel, -5, SWT.TOP);
> svrTable.setLayoutData(ld);

> // Create table columns
> TableColumn svrTableHosts = new TableColumn(svrTable, SWT.NONE);
> svrTableHosts.setText("Name");
> svrTableHosts.setWidth(300);

> // ----> getWidth() still zero at this point <----

> TableColumn svrTableLocs = new TableColumn(svrTable, SWT.NONE);
> svrTableLocs.setText("Location");

> // Open window
> shell.layout();
> shell.open();

> I'm sure I'm not doing something right :-) Any pointers would be
> appreciated - thanks!
> Mike
Re: SWT Problems on Linux [message #443360 is a reply to message #441701] Thu, 23 September 2004 14:09 Go to previous message
Andy Czerwonka is currently offline Andy CzerwonkaFriend
Messages: 42
Registered: July 2009
Member
Mike Simpson wrote:

[snip]
> The app works perfectly on Windows, but when I run it under Linux, I have
> two problems: first, my menu doesn't show up until I resize the shell.
[snip]

I have exactly the same problem. I'm runninng Eclipse v3.0 on SuSE 9.1. It
seem to have the problem with JFace window menus and not staight SWT. I
may be wrong.
Previous Topic:Create a custom DND transfer type or use String?
Next Topic:Using a Composite within a JFace Application Window
Goto Forum:
  


Current Time: Thu Apr 25 10:40:14 GMT 2024

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

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

Back to the top