Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0e151164052a8ac3ba475dcc3bba1bf9f8b2cf2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*******************************************************************************
 * Copyright (c) 2018 Red Hat and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Red Hat - initial API and implementation
 *******************************************************************************/
package org.eclipse.swt.tests.gtk.snippets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Bug375385_ShellFullScreen
{
    public static void main(String[] args)
    {
        Display display = new Display();
        
        Shell parentShell = new Shell(display);
        parentShell.setText("Parent widget.shell");
        parentShell.setSize(400, 300);
                
        final Shell childShell = new Shell(parentShell, SWT.APPLICATION_MODAL | SWT.RESIZE | SWT.CLOSE);
        childShell.setSize(300, 200);
        childShell.setText("Child widget.shell");        
        
        childShell.addMouseListener(new MouseListener()
        {   
            @Override
            public void mouseUp(MouseEvent event)
            {   
                
            }
            
            @Override
            public void mouseDown(MouseEvent event)
            {
                
            }
            
            @Override
            public void mouseDoubleClick(MouseEvent event)
            {
                // Toggle full screen mode: works on Mac and Windows, won't work on Linux
                System.out.println("Full screen: " + childShell.getFullScreen());
                
                childShell.setFullScreen(! childShell.getFullScreen());
                
                System.out.println("Full screen: " + childShell.getFullScreen());                
            }
        });
        
        parentShell.open();
        childShell.open();
                
        while (! parentShell.isDisposed())
        {
            if (! display.readAndDispatch())
            {
                display.sleep();
            }
        }
        display.dispose();
    }    
}

Back to the top