本文整理汇总了Java中org.w3c.dom.events.EventTarget类的典型用法代码示例。如果您正苦于以下问题:Java EventTarget类的具体用法?Java EventTarget怎么用?Java EventTarget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventTarget类属于org.w3c.dom.events包,在下文中一共展示了EventTarget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeEventListeners
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
/**
* Removes the event listeners from the document.
*/
protected void removeEventListeners(EventTarget doc) {
if (isCSSNavigableDocument) {
CSSNavigableDocument cnd = (CSSNavigableDocument) doc;
cnd.removeCSSNavigableDocumentListener
(cssNavigableDocumentListener);
} else {
doc.removeEventListener("DOMAttrModified",
domAttrModifiedListener,
false);
doc.removeEventListener("DOMNodeInserted",
domNodeInsertedListener,
false);
doc.removeEventListener("DOMNodeRemoved",
domNodeRemovedListener,
false);
doc.removeEventListener("DOMSubtreeModified",
domSubtreeModifiedListener,
false);
doc.removeEventListener("DOMCharacterDataModified",
domCharacterDataModifiedListener,
false);
}
}
示例2: dispatchTextEvent
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
/**
* Dispatch a DOM 3 Text event.
*/
protected void dispatchTextEvent(GraphicsNodeKeyEvent evt) {
FocusManager fmgr = context.getFocusManager();
if (fmgr == null) {
return;
}
Element targetElement = (Element) fmgr.getCurrentEventTarget();
if (targetElement == null) {
targetElement = context.getDocument().getDocumentElement();
}
DocumentEvent d = (DocumentEvent) targetElement.getOwnerDocument();
DOMTextEvent textEvt = (DOMTextEvent) d.createEvent("TextEvent");
textEvt.initTextEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"textInput",
true,
true,
null,
String.valueOf(evt.getKeyChar()));
try {
((EventTarget) targetElement).dispatchEvent(textEvt);
} catch (RuntimeException e) {
ua.displayError(e);
}
}
示例3: mouseWheelMoved
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
public void mouseWheelMoved(GraphicsNodeMouseWheelEvent evt) {
Document doc = context.getPrimaryBridgeContext().getDocument();
Element targetElement = doc.getDocumentElement();
DocumentEvent d = (DocumentEvent) doc;
SVGOMWheelEvent wheelEvt
= (SVGOMWheelEvent) d.createEvent("WheelEvent");
wheelEvt.initWheelEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"wheel",
true,
true,
null,
evt.getWheelDelta());
try {
((EventTarget)targetElement).dispatchEvent(wheelEvt);
} catch (RuntimeException e) {
ua.displayError(e);
}
}
示例4: handleEvent
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
/**
* Handles the event.
*/
public void handleEvent(Event evt) {
EventTarget target = evt.getTarget();
if (target instanceof XBLOMDefinitionElement) {
// only handle definition elements in document-level scope
if (getXblBoundElement((Node) target) == null) {
defsToBeRemoved.add(target);
}
} else if (target instanceof XBLOMImportElement) {
// only handle import elements in document-level scope
if (getXblBoundElement((Node) target) == null) {
importsToBeRemoved.add(target);
}
}
Node parent = getXblParentNode((Node) target);
if (parent != null) {
nodesToBeInvalidated.add(parent);
}
}
示例5: fireDOMFocusInEvent
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
/**
* Fires a 'DOMFocusIn' event to the specified target.
*
* @param target the newly focussed event target
* @param relatedTarget the previously focussed event target
*/
protected void fireDOMFocusInEvent(EventTarget target,
EventTarget relatedTarget) {
DocumentEvent docEvt =
(DocumentEvent)((Element)target).getOwnerDocument();
DOMUIEvent uiEvt = (DOMUIEvent)docEvt.createEvent("UIEvents");
uiEvt.initUIEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMFocusIn",
true,
false, // canBubbleArg
null, // cancelableArg
0); // detailArg
int limit = DefaultXBLManager.computeBubbleLimit((Node) relatedTarget,
(Node) target);
((AbstractEvent) uiEvt).setBubbleLimit(limit);
target.dispatchEvent(uiEvt);
}
示例6: fireDOMFocusOutEvent
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
/**
* Fires a 'DOMFocusOut' event to the specified target.
*
* @param target the previously focussed event target
* @param relatedTarget the newly focussed event target
*/
protected void fireDOMFocusOutEvent(EventTarget target,
EventTarget relatedTarget) {
DocumentEvent docEvt =
(DocumentEvent)((Element)target).getOwnerDocument();
DOMUIEvent uiEvt = (DOMUIEvent)docEvt.createEvent("UIEvents");
uiEvt.initUIEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMFocusOut",
true,
false, // canBubbleArg
null, // cancelableArg
0); // detailArg
int limit = DefaultXBLManager.computeBubbleLimit((Node) target,
(Node) relatedTarget);
((AbstractEvent) uiEvt).setBubbleLimit(limit);
target.dispatchEvent(uiEvt);
}
示例7: removeUIEventListeners
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
public void removeUIEventListeners(Document doc) {
EventTarget evtTarget = (EventTarget)doc.getDocumentElement();
synchronized (eventListenerSet) {
Iterator i = eventListenerSet.iterator();
while (i.hasNext()) {
EventListenerMememto elm = (EventListenerMememto)i.next();
NodeEventTarget et = elm.getTarget();
if (et == evtTarget) {
EventListener el = elm.getListener();
boolean uc = elm.getUseCapture();
String t = elm.getEventType();
boolean n = elm.getNamespaced();
if (et == null || el == null || t == null) {
continue;
}
if (n) {
String ns = elm.getNamespaceURI();
et.removeEventListenerNS(ns, t, el, uc);
} else {
et.removeEventListener(t, el, uc);
}
}
}
}
}
示例8: handleEvent
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
public void handleEvent(Event e) {
DOMMouseEvent evt = (DOMMouseEvent) e;
DOMMouseEvent newMouseEvent = (DOMMouseEvent)
// DOM Level 2 6.5 cast from Document to DocumentEvent is ok
((DocumentEvent)imgElement.getOwnerDocument()).createEvent("MouseEvents");
newMouseEvent.initMouseEventNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
evt.getType(),
evt.getBubbles(),
evt.getCancelable(),
evt.getView(),
evt.getDetail(),
evt.getScreenX(),
evt.getScreenY(),
evt.getClientX(),
evt.getClientY(),
evt.getButton(),
(EventTarget)imgElement,
evt.getModifiersString());
((EventTarget)imgElement).dispatchEvent(newMouseEvent);
}
示例9: DomIterator
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
/**
* Constructs and initializes an iterator.
*/
protected DomIterator(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
{
if (!root.isSupported("MutationEvents", "2.0"))
{
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
"Iterator needs mutation events", root, 0);
}
this.root = root;
this.whatToShow = whatToShow;
this.filter = filter;
this.expandEntityReferences = entityReferenceExpansion;
// start condition: going right, seen nothing yet.
reference = null;
right = true;
EventTarget target = (EventTarget) root;
target.addEventListener("DOMNodeRemoved", this, false);
}
示例10: DomIterator
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
/**
* Constructs and initializes an iterator.
*/
protected DomIterator(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
{
if (!root.isSupported("MutationEvents", "2.0"))
{
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
"Iterator needs mutation events", root, 0);
}
this.root = root;
this.whatToShow = whatToShow;
this.filter = filter;
this.expandEntityReferences = entityReferenceExpansion;
// start condition: going right, seen nothing yet.
reference = null;
right = true;
EventTarget target = (EventTarget) root;
target.addEventListener("DOMNodeRemoved", this, false);
}
示例11: changed
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
@Override
public void changed (ObservableValue<? extends State> ov, State oldState, State newState) {
if (newState == Worker.State.SUCCEEDED) {
EventListener listener = event -> {
final String href = ((Element)event.getTarget()).getAttribute(HTML_LINK);
if (href != null) {
String domEventType = event.getType();
if (domEventType.equals(EVENT_CLICK)) {
showPage(href);
} else if (domEventType.equals(EVENT_MOUSEOVER)) {
showStatus(href);
} else if (domEventType.equals(EVENT_MOUSEOUT)) {
showStatus(BLANK);
}
}
};
Document doc = myPage.getEngine().getDocument();
NodeList nodes = doc.getElementsByTagName("a");
for (int i = 0; i < nodes.getLength(); i++) {
EventTarget node = (EventTarget)nodes.item(i);
node.addEventListener(EVENT_CLICK, listener, false);
node.addEventListener(EVENT_MOUSEOVER, listener, false);
node.addEventListener(EVENT_MOUSEOUT, listener, false);
}
}
}
示例12: changed
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
@Override public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
if (State.SUCCEEDED.equals(newValue)) {
Document document = webView.getEngine().getDocument();
NodeList anchors = document.getElementsByTagName(ANCHOR_TAG);
for (int i = 0; i < anchors.getLength(); i++) {
Node node = anchors.item(i);
EventTarget eventTarget = (EventTarget) node;
eventTarget.addEventListener(CLICK_EVENT, this, false);
}
}
}
示例13: addListenerToAllHyperlinkItems
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
private void addListenerToAllHyperlinkItems(EventListener listener) {
final Document doc = myEngine.getDocument();
if (doc != null) {
final NodeList nodeList = doc.getElementsByTagName("a");
for (int i = 0; i < nodeList.getLength(); i++) {
((EventTarget)nodeList.item(i)).addEventListener(EVENT_TYPE_CLICK, listener, false);
}
}
}
示例14: changed
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
if (SUCCEEDED.equals(newValue)) {
Document document = webView.getEngine().getDocument();
NodeList anchors = document.getElementsByTagName(ANCHOR_TAG);
for (int i = 0; i < anchors.getLength(); i++) {
Node node = anchors.item(i);
EventTarget eventTarget = (EventTarget) node;
eventTarget.addEventListener(CLICK_EVENT, this, false);
}
}
}
示例15: addEventListeners
import org.w3c.dom.events.EventTarget; //导入依赖的package包/类
/**
* Adds event listeners to the document to track CSS changes.
*/
protected void addEventListeners(EventTarget doc) {
if (isCSSNavigableDocument) {
cssNavigableDocumentListener = new CSSNavigableDocumentHandler();
CSSNavigableDocument cnd = (CSSNavigableDocument) doc;
cnd.addCSSNavigableDocumentListener(cssNavigableDocumentListener);
} else {
domAttrModifiedListener = new DOMAttrModifiedListener();
doc.addEventListener("DOMAttrModified",
domAttrModifiedListener,
false);
domNodeInsertedListener = new DOMNodeInsertedListener();
doc.addEventListener("DOMNodeInserted",
domNodeInsertedListener,
false);
domNodeRemovedListener = new DOMNodeRemovedListener();
doc.addEventListener("DOMNodeRemoved",
domNodeRemovedListener,
false);
domSubtreeModifiedListener = new DOMSubtreeModifiedListener();
doc.addEventListener("DOMSubtreeModified",
domSubtreeModifiedListener,
false);
domCharacterDataModifiedListener =
new DOMCharacterDataModifiedListener();
doc.addEventListener("DOMCharacterDataModified",
domCharacterDataModifiedListener,
false);
}
}