[Solved] SWT – Snap display to right hand side of the screen


Here is some code that utilizes the functions found by sambi:

public static void main(String[] args)
{
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout(SWT.VERTICAL));
    shell.setText("StackOverflow");

    Monitor primary = display.getPrimaryMonitor();

        /* Get the available screen size (without start menu) */
    Rectangle area = primary.getClientArea();

    shell.pack();
    /* Set the shell size */
    shell.setBounds(area.x + area.width / 2, area.y, area.width / 2, area.height);
    shell.open();
    while (!shell.isDisposed())
    {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

Tested on both Linux (panel left and bottom) and Windows 7 (start menu left).

0

solved SWT – Snap display to right hand side of the screen