MenuItem behaves differently on x86 and iPAQ [message #35127] |
Wed, 20 November 2002 19:49 |
Chen Shu Messages: 2 Registered: July 2009 |
Junior Member |
|
|
Hi,
In the following code, when File MenuItem is clicked, the label changes from
blank to "clicked" and "clicked again" on x86, but it does not change on
iPAQ. Can somebody tell me why?
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
public class HelloWorld
{
public static void main(String args[])
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello World");
FillLayout layout = new FillLayout();
layout.type = SWT.VERTICAL;
shell.setLayout(layout);
final Label label = new Label(shell, SWT.CENTER|SWT.BORDER|SWT.WRAP);
Menu menubar = new Menu(shell, SWT.BAR);
shell.setMenuBar(menubar);
MenuItem fileMenuItem = new MenuItem(menubar, SWT.CASCADE);
fileMenuItem.setText("File");
fileMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (!label.getText().equals("clicked"))
label.setText("clicked");
else
label.setText("clicked again");
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
Thanks,
-Chen
|
|
|
Powered by
FUDForum. Page generated in 0.03674 seconds