Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 148422 Details for
Bug 290903
[SWT/AWT] addFilter does not fire using JWS with type SWT.FocusIn/SWT.FocusOut
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Java source code snippet of SWT.FocusIn/SWT.FocusOut bug
FocusBugSnippetMain.java (text/plain), 2.99 KB, created by
square_96
on 2009-09-30 09:27:38 EDT
(
hide
)
Description:
Java source code snippet of SWT.FocusIn/SWT.FocusOut bug
Filename:
MIME Type:
Creator:
square_96
Created:
2009-09-30 09:27:38 EDT
Size:
2.99 KB
patch
obsolete
>import org.eclipse.swt.SWT; >import org.eclipse.swt.browser.Browser; >import org.eclipse.swt.graphics.Rectangle; >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.Event; >import org.eclipse.swt.widgets.Listener; >import org.eclipse.swt.widgets.MessageBox; >import org.eclipse.swt.widgets.Monitor; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.Tree; > > >public class FocusBugSnippetMain { > > /** > * @param args > */ > Display display = new Display(); > Shell shell = new Shell(display, SWT.NONE); > Browser webBrowser; > Composite webComposite = null; > > Listener shellBehaviorListener = new Listener(){ > > public void handleEvent(Event event) { > // TODO Auto-generated method stub > switch(event.type) > { > case SWT.FocusOut: > //if the focus is lost to anything other than this app terminate content display > if(display.getActiveShell() == null) > { > display.getDefault().syncExec(new Runnable(){ > public void run() > { > webBrowser.setVisible(false); > }}); > } > break; > case SWT.FocusIn: > //when focus is gained, and browser is no visible, restore the viewing > if(display.getActiveShell() != null && > !webBrowser.isVisible()) > { > display.getDefault().syncExec(new Runnable(){ > public void run() > { > webBrowser.setVisible(true); > shell.update(); > }}); > } > break; > } > }}; > > public FocusBugSnippetMain() > { > // TODO Auto-generated method stub > shell.setLayout(new GridLayout()); > shell.setSize(500, 500); > shell.setMinimumSize(500, 500); > > //center the shell display on the screen > Monitor primary = display.getPrimaryMonitor(); > Rectangle monitorRect = primary.getBounds(); > Rectangle shellRect = shell.getBounds(); > int startShellX = monitorRect.x + (monitorRect.width - shellRect.width) / 2; > int startShellY = monitorRect.y + (monitorRect.height - shellRect.height) / 2; > shell.setLocation(startShellX, startShellY); > > //set title of the shell frame > shell.setText("Focus Bug Snippet"); > > webComposite = new Composite(shell, SWT.SINGLE | SWT.BORDER); > webComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true)); > webComposite.setBounds(0, 0, shellRect.width, shellRect.height); > webComposite.setSize(shellRect.width, shellRect.height); > webBrowser = new Browser(webComposite, SWT.SINGLE | SWT.BORDER); > webBrowser.setSize(shellRect.width, shellRect.height); > webBrowser.setUrl("www.google.com"); > > shell.getDisplay().addFilter(SWT.FocusOut, shellBehaviorListener); > shell.getDisplay().addFilter(SWT.FocusIn, shellBehaviorListener); > > shell.open(); > > while (!shell.isDisposed()) > { > if (!display.readAndDispatch()) > display.sleep(); > } > > > shell.dispose(); > display.dispose(); > } > > public static void main(String[] args) { > FocusBugSnippetMain snippetMain = new FocusBugSnippetMain(); > } > >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 290903
: 148422