當前位置: 首頁>>代碼示例>>Java>>正文


Java EventTarget.addEventListener方法代碼示例

本文整理匯總了Java中org.w3c.dom.events.EventTarget.addEventListener方法的典型用法代碼示例。如果您正苦於以下問題:Java EventTarget.addEventListener方法的具體用法?Java EventTarget.addEventListener怎麽用?Java EventTarget.addEventListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.w3c.dom.events.EventTarget的用法示例。


在下文中一共展示了EventTarget.addEventListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:27,代碼來源:DomIterator.java

示例2: 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);
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:27,代碼來源:DomIterator.java

示例3: 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);
        }
    }
}
 
開發者ID:duke-compsci308-fall2015,項目名稱:lab_browser,代碼行數:27,代碼來源:BrowserView.java

示例4: 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);
        }
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:12,代碼來源:HyperlinkRedirectListener.java

示例5: 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);
        }
    }
}
 
開發者ID:tbressler,項目名稱:waterrower-workout,代碼行數:13,代碼來源:HyperlinkRedirectListener.java

示例6: 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);
    }
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:33,代碼來源:CSSEngine.java

示例7: addDomMutationListeners

import org.w3c.dom.events.EventTarget; //導入方法依賴的package包/類
/**
 * Registers DOM Mutation Listener on the given document.
 *
 * @param doc
 *            The given document
 */
protected void addDomMutationListeners(Document doc) {
    EventTarget target = (EventTarget) doc;
    nodeInsertion = new NodeInsertionHandler();
    target.addEventListener(NODE_INSERTED, nodeInsertion, true);
    nodeRemoval = new NodeRemovalHandler();
    target.addEventListener(NODE_REMOVED, nodeRemoval, true);
    attrModification = new AttributeModificationHandler();
    target.addEventListener(ATTRIBUTE_MODIFIED, attrModification,
            true);
    charDataModification = new CharDataModificationHandler();
    target.addEventListener(CHAR_DATA_MODIFIED,
            charDataModification, true);
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:20,代碼來源:DOMViewer.java

示例8: 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);
        }
    }
}
 
開發者ID:headwirecom,項目名稱:aem-ide-tooling-4-intellij,代碼行數:13,代碼來源:HyperlinkRedirectListener.java

示例9: addMediaElementEventListeners

import org.w3c.dom.events.EventTarget; //導入方法依賴的package包/類
static void addMediaElementEventListeners(
        EventTarget target, MediaModel media) {
    // To play the media with SmilPlayer, we should add them
    // as EventListener into an EventTarget.
    target.addEventListener(SMIL_MEDIA_START_EVENT, media, false);
    target.addEventListener(SMIL_MEDIA_END_EVENT, media, false);
    target.addEventListener(SMIL_MEDIA_PAUSE_EVENT, media, false);
    target.addEventListener(SMIL_MEDIA_SEEK_EVENT, media, false);
}
 
開發者ID:moezbhatti,項目名稱:qksms,代碼行數:10,代碼來源:SmilHelper.java

示例10: addParElementEventListeners

import org.w3c.dom.events.EventTarget; //導入方法依賴的package包/類
static void addParElementEventListeners(
        EventTarget target, SlideModel slide) {
    // To play the slide with SmilPlayer, we should add it
    // as EventListener into an EventTarget.
    target.addEventListener(SMIL_SLIDE_START_EVENT, slide, false);
    target.addEventListener(SMIL_SLIDE_END_EVENT, slide, false);
}
 
開發者ID:moezbhatti,項目名稱:qksms,代碼行數:8,代碼來源:SmilHelper.java

示例11: enableStop

import org.w3c.dom.events.EventTarget; //導入方法依賴的package包/類
/**
 * Enable capturing of 'mousemove' and 'mouseup' events.
 */
protected void enableStop() {
  EventTarget targ = svgp.getDocument().getRootElement();
  targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEMOVE, this, false);
  targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEUP, this, false);
  // FIXME: listen on the background object!
  targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEOUT, this, false);
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:11,代碼來源:DragableArea.java

示例12: addEventListener

import org.w3c.dom.events.EventTarget; //導入方法依賴的package包/類
/**
 * Add an event listener to the Element.
 *
 * @param tag Element to add the listener
 * @param truedim Tool number for the Element
 */
private void addEventListener(final Element tag, final int truedim) {
  EventTarget targ = (EventTarget) tag;
  targ.addEventListener(SVGConstants.SVG_EVENT_CLICK, new EventListener() {
    @Override
    public void handleEvent(Event evt) {
      proj.toggleDimInverted(truedim);
      context.visChanged(proj);
    }
  }, false);
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:17,代碼來源:ParallelAxisVisualization.java

示例13: addEventListener

import org.w3c.dom.events.EventTarget; //導入方法依賴的package包/類
/**
 * Add an event listener to the Element
 *
 * @param tag Element to add the listener
 * @param axis Axis number (including hidden axes)
 */
private void addEventListener(final Element tag, final int axis) {
  EventTarget targ = (EventTarget) tag;
  targ.addEventListener(SVGConstants.SVG_EVENT_CLICK, new EventListener() {
    @Override
    public void handleEvent(Event evt) {
      if(proj.getVisibleDimensions() > 2) {
        proj.toggleAxisVisible(axis);
        context.visChanged(proj);
      }
    }
  }, false);
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:19,代碼來源:AxisVisibilityVisualization.java

示例14: fullRedraw

import org.w3c.dom.events.EventTarget; //導入方法依賴的package包/類
@Override
public void fullRedraw() {
  setupCanvas();
  setupCSS(svgp);
  final StyleLibrary style = context.getStyleLibrary();
  double dotsize = style.getLineWidth(StyleLibrary.PLOT);

  for(DBIDIter id = sample.getSample().iter(); id.valid(); id.advance()) {
    double[] v = proj.fastProjectDataToRenderSpace(rel.get(id));
    if(v[0] != v[0] || v[1] != v[1]) {
      continue; // NaN!
    }
    Element tooltip = makeTooltip(id, v[0], v[1], dotsize);
    SVGUtil.addCSSClass(tooltip, TOOLTIP_HIDDEN);

    // sensitive area.
    Element area = svgp.svgRect(v[0] - dotsize, v[1] - dotsize, 2 * dotsize, 2 * dotsize);
    SVGUtil.addCSSClass(area, TOOLTIP_AREA);

    EventTarget targ = (EventTarget) area;
    targ.addEventListener(SVGConstants.SVG_MOUSEOVER_EVENT_TYPE, hoverer, false);
    targ.addEventListener(SVGConstants.SVG_MOUSEOUT_EVENT_TYPE, hoverer, false);
    targ.addEventListener(SVGConstants.SVG_CLICK_EVENT_TYPE, hoverer, false);

    // NOTE: do not change the sequence in which these are inserted!
    layer.appendChild(area);
    layer.appendChild(tooltip);
  }
}
 
開發者ID:elki-project,項目名稱:elki,代碼行數:30,代碼來源:AbstractTooltipVisualization.java

示例15: attachTo

import org.w3c.dom.events.EventTarget; //導入方法依賴的package包/類
protected void attachTo(Element e) {
    EventTarget et = (EventTarget) e;
    // Node{Inserted,Removed} is fired *before* the change. This is better;
    // fired *after* it has taken effect.
    et.addEventListener("DOMSubtreeModified", this, false);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:ElementLook.java


注:本文中的org.w3c.dom.events.EventTarget.addEventListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。