Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JBrowser Source Code Files
JBrowser Source Code Files are provided in the
source package file.
You can download JBrowser source package as described in the previous tutorial and go to the "src" sub-folder to view Source Code files.
You can also browse JBrowser Source Code files below:
✍: FYIcenter
⏎ org/mozilla/browser/impl/FocusWatcher.java
package org.mozilla.browser.impl;
import static java.awt.event.FocusEvent.FOCUS_GAINED;
import static org.mozilla.browser.MozillaExecutor.swingAsyncExec;
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.AWTEventListener;
import java.awt.event.FocusEvent;
import java.awt.event.WindowEvent;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.swing.SwingUtilities;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import ru.atomation.jbrowser.impl.JBrowserCanvas;
public class FocusWatcher {
static Log log = LogFactory.getLog(FocusWatcher.class);
private static Map<Window, List<JBrowserCanvas>> xx = new HashMap<Window, List<JBrowserCanvas>>();
public static void register(final JBrowserCanvas c) {
swingAsyncExec(new Runnable() { public void run() {
Window win = SwingUtilities.getWindowAncestor(c);
assert win!=null;
boolean wasEmpty = xx.isEmpty();
List<JBrowserCanvas> cs = xx.get(win);
if (cs==null) {
cs = new LinkedList<JBrowserCanvas>();
xx.put(win, cs);
}
cs.add(c);
if (wasEmpty) {
Toolkit.getDefaultToolkit().
addAWTEventListener(gfl,
FocusEvent.FOCUS_EVENT_MASK
| WindowEvent.WINDOW_FOCUS_EVENT_MASK);
}
}});
}
public static void unregister(final JBrowserCanvas c) {
swingAsyncExec(new Runnable() { public void run() {
//search window the canvas was registered in
for (Window win : xx.keySet()) {
List<JBrowserCanvas> cs = xx.get(win);
assert cs!=null;
if (cs.remove(c)) {
if (cs.isEmpty()) {
xx.remove(win);
}
break;
}
}
if (xx.isEmpty()) {
Toolkit.getDefaultToolkit().
removeAWTEventListener(gfl);
}
}});
}
private static GlobalFocusListener gfl = new GlobalFocusListener();
static class GlobalFocusListener implements AWTEventListener {
public void eventDispatched(AWTEvent ev) {
log.debug(ev.getSource().getClass().getSimpleName()+ " "+ev); //$NON-NLS-1$
if (!(ev instanceof FocusEvent)) return;
FocusEvent fev = (FocusEvent) ev;
if (fev.getID()==FOCUS_GAINED &&
(ev.getSource() instanceof Component))
{
Component cmp = (Component) ev.getSource();
if (cmp instanceof JBrowserCanvas) {
JBrowserCanvas c = (JBrowserCanvas) cmp;
c.onFocusMovedTo(cmp);
} else {
//notify one of the canvas in window
//to deactivate gecko
Window win = SwingUtilities.getWindowAncestor(cmp);
if (win!=null) {
List<JBrowserCanvas> cs = xx.get(win);
if (cs!=null && !cs.isEmpty()) {
JBrowserCanvas c = (JBrowserCanvas) cs.get(0);
c.onFocusMovedTo(cmp);
}
}
}
}
}
}
}
⏎ org/mozilla/browser/impl/FocusWatcher.java
Or download all of them as a single archive file:
File name: jbrowser-1.9-fyi.zip File size: 625318 bytes Release date: 2022-11-10 Download
⇐ Download and Install JBrowser Source Package
2017-07-17, ≈25🔥, 1💬
Popular Posts:
Guava is a suite of core and expanded libraries that include utility classes, google's collections, ...
JDK 7 tools.jar is the JAR file for JDK 7 tools. It contains Java classes to support different JDK t...
What Is ojdbc5.jar for Oracle 11g R1? ojdbc5.jar for Oracle 11g R1 is the JAR files of ojdbc.jar, JD...
How to download and install Apache XMLBeans-2.6.0.zip? If you want to try the XMLBeans Java library,...
maven-compat-3.8.6.jar is the JAR file for Apache Maven 3.8.6 Compact module. The JAR file name may ...