Strange Shell behaviour [message #453939] |
Thu, 14 April 2005 12:59 |
hortiz Mising name Messages: 96 Registered: July 2009 |
Member |
|
|
Hi,
I used in my application a Shell with ALWAYS_ON_TOP style, to allow users
to always see some important information (server alarms, ...).
I work on Linux with SuSE 8.2.
But if the user clickes on the clock in the task bar while this shell is
displayed, it disappears.
Here is a sample code (two classes: Main.java and SpyContainer.java)
/*** Main.java ******************************/
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Main {
private static Display display;
public static void main(String[] args) {
display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new GridLayout());
Button openSpyButton = new Button(shell, SWT.PUSH);
openSpyButton.setText("Open Spy");
openSpyButton.setLayoutData(new GridData());
openSpyButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
SpyContainer spyContainer = new SpyContainer(display);
spyContainer.getSpyComposite().layout();
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
/*** SpyContainer.java **********************/
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class SpyContainer {
private Shell spyShell;
private Composite spyComposite;
public SpyContainer(Display display) {
spyShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP);
// spyShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP |
SWT.PRIMARY_MODAL);
// spyShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP |
SWT.APPLICATION_MODAL);
// spyShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP |
SWT.SYSTEM_MODAL);
// spyShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP |
SWT.MODELESS);
spyShell.setLayout(new FillLayout(SWT.VERTICAL));
spyComposite = new Composite(spyShell, SWT.NONE);
spyComposite.setLayout(new GridLayout());
spyComposite.setBackground(display.getSystemColor(SWT.COLOR_ DARK_RED));
Label spyLabel = new Label(spyComposite, SWT.NONE);
spyLabel.setText("Spy Label");
spyLabel.setLayoutData(new GridData());
spyShell.setSize(300, 300);
spyShell.open();
}
public Composite getSpyComposite() {
return spyComposite;
}
}
|
|
|
|
Re: Strange Shell behaviour [message #453946 is a reply to message #453939] |
Thu, 14 April 2005 14:45 |
Steve Northover Messages: 1636 Registered: July 2009 |
Senior Member |
|
|
No idea why this would happen. ON_TOP shells override the window manager so
it should not be hiding it. Try creating the spy as a child of the other
shell?
"hortiz" <hortiz@xxxxx.com> wrote in message
news:3cb48cd36c1972c97b862078d7e23aee$1@www.eclipse.org...
> Hi,
>
> I used in my application a Shell with ALWAYS_ON_TOP style, to allow users
> to always see some important information (server alarms, ...).
>
> I work on Linux with SuSE 8.2.
>
> But if the user clickes on the clock in the task bar while this shell is
> displayed, it disappears.
>
> Here is a sample code (two classes: Main.java and SpyContainer.java)
>
> /*** Main.java ******************************/
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.events.SelectionAdapter;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class Main {
>
> private static Display display;
>
> public static void main(String[] args) {
>
> display = new Display ();
> Shell shell = new Shell (display);
> shell.setLayout(new GridLayout());
>
> Button openSpyButton = new Button(shell, SWT.PUSH);
> openSpyButton.setText("Open Spy");
> openSpyButton.setLayoutData(new GridData());
> openSpyButton.addSelectionListener(new SelectionAdapter() {
> public void widgetSelected(SelectionEvent event) {
> SpyContainer spyContainer = new SpyContainer(display);
> spyContainer.getSpyComposite().layout();
> }
> });
>
> shell.open();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> display.dispose();
> }
> }
>
>
> /*** SpyContainer.java **********************/
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.layout.GridData;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Label;
> import org.eclipse.swt.widgets.Shell;
>
> public class SpyContainer {
>
> private Shell spyShell;
> private Composite spyComposite;
>
> public SpyContainer(Display display) {
>
> spyShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP);
> // spyShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP |
> SWT.PRIMARY_MODAL);
> // spyShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP |
> SWT.APPLICATION_MODAL);
> // spyShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP |
> SWT.SYSTEM_MODAL);
> // spyShell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP |
> SWT.MODELESS);
>
> spyShell.setLayout(new FillLayout(SWT.VERTICAL));
> spyComposite = new Composite(spyShell, SWT.NONE);
> spyComposite.setLayout(new GridLayout());
>
> spyComposite.setBackground(display.getSystemColor(SWT.COLOR_ DARK_RED));
>
> Label spyLabel = new Label(spyComposite, SWT.NONE);
> spyLabel.setText("Spy Label");
> spyLabel.setLayoutData(new GridData());
> spyShell.setSize(300, 300);
> spyShell.open();
> }
>
> public Composite getSpyComposite() {
> return spyComposite;
> }
> }
>
>
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03445 seconds