View Single Post
Posts: 3 | Thanked: 0 times | Joined on Feb 2009 @ Madrid - Spain
#14
[QUOTE=jaeezzy;208406]Here, ...How can it made to cover the whole screen? Thanks.

One thing that is highly recommended is to download the source code of the jalimo-swt-example2. As it is not easy to find it (I don't remember the site) I will copy below this source. As you can see, there is a command (related with fd.open() ), that will allow to go to full screen. It is very simple and I have tested it. It works. Your calculator will be great :-)
Here is the source:

//package org.jalimo.examples.swt;

import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;

public class SwtExample2
{
Display display;
Shell shell;
Button fullscreenButton;
Button fileButton;
Table table;
FileDialog fd;

public static void main(String[] args)
{
new SwtExample2();
}

public SwtExample2()
{
Display.setAppName("SWT Example Two");
display = new Display();

shell = new Shell(display);

display.addFilter(SWT.KeyDown, new Listener()
{
public void handleEvent(Event e)
{
if (e.keyCode == SWT.F6)
toggleFullscreen();
}
});

createGUI();

shell.open();

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

private void toggleFullscreen()
{
boolean b = !shell.getFullScreen();
fullscreenButton.setSelection(b);
shell.setFullScreen(b);
}

private void createGUI()
{
fd = new FileDialog(shell, SWT.OPEN);
fd.setText("FooBar!");

Menu bar = new Menu(shell, SWT.BAR);
MenuItem mainHeader = new MenuItem(bar, SWT.CASCADE); mainHeader.setText("Main");
Menu main = new Menu(shell, SWT.DROP_DOWN);
MenuItem item = new MenuItem(main, SWT.PUSH); item.setText("toggle fullscreen");
item.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent se)
{
toggleFullscreen();
}
});

MenuItem item2 = new MenuItem(bar, SWT.PUSH); item2.setText("Exit");
item2.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent se)
{
shell.close();
System.exit(0);
}
});

mainHeader.setMenu(main);
shell.setMenuBar(bar);

shell.setLayout(new FillLayout(SWT.VERTICAL));

Group upper = new Group(shell, SWT.NONE);
upper.setLayout(new FillLayout());

fullscreenButton = new Button(upper, SWT.TOGGLE);
fullscreenButton.setText("toggle fullscreen");
fullscreenButton.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent se)
{
boolean b = fullscreenButton.getSelection();
shell.setFullScreen(b);
}
});

fileButton = new Button(upper, SWT.PUSH);
fileButton.setText("open file\ndialog");
fileButton.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent se)
{
fd.open();
}
});

table = new Table (shell, SWT.VIRTUAL | SWT.BORDER);
table.setItemCount (1000);
table.addListener (SWT.SetData, new Listener () {
public void handleEvent (Event event) {
TableItem item = (TableItem) event.item;
int index = table.indexOf (item);
item.setText ("Item " + index);
}
});

}

}

Don't forget to comment the "package" line.
Hope that helps!!