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, ≈34🔥, 1💬
Popular Posts:
What is jxl.jar 2.6.12? jxl.jar 2.6.12 is the JAR file for Java Excel API 2.6.12, which is a Java li...
JRE 8 rt.jar is the JAR file for JRE 8 RT (Runtime) libraries. JRE (Java Runtime) 8 is the runtime e...
Apache Avalon began in 1999 as the Java Apache Server Framework and in late 2002 separated from the ...
Apache BCEL Source Code Files are inside the Apache BCEL source package file like bcel-6.6.1-src.zip...
The Java Naming and Directory Interface (JNDI) is part of the Java platform, providing applications ...