当前位置: 首页>>代码示例>>Java>>正文


Java ContainerEvent.COMPONENT_REMOVED属性代码示例

本文整理汇总了Java中java.awt.event.ContainerEvent.COMPONENT_REMOVED属性的典型用法代码示例。如果您正苦于以下问题:Java ContainerEvent.COMPONENT_REMOVED属性的具体用法?Java ContainerEvent.COMPONENT_REMOVED怎么用?Java ContainerEvent.COMPONENT_REMOVED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.event.ContainerEvent的用法示例。


在下文中一共展示了ContainerEvent.COMPONENT_REMOVED属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processContainerEvent

/**
 * Called when a container event occurs if container events are enabled.
 * This method calls any registered listeners.
 *
 * @param e The event that occurred.
 */
protected void processContainerEvent(ContainerEvent e)
{
  if (containerListener == null)
    return;
  switch (e.id)
    {
    case ContainerEvent.COMPONENT_ADDED:
      containerListener.componentAdded(e);
      break;

    case ContainerEvent.COMPONENT_REMOVED:
      containerListener.componentRemoved(e);
      break;
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:21,代码来源:Container.java

示例2: focusedComponentChanged

@Override
protected void focusedComponentChanged(final Component component, final AWTEvent cause) {
  EditorWindow newWindow = null;

  if (component != null) {
    newWindow = findWindowWith(component);
  }
  else if (cause instanceof ContainerEvent && cause.getID() == ContainerEvent.COMPONENT_REMOVED) {
    // do not change current window in case of child removal as in JTable.removeEditor
    // otherwise Escape in a toolwindow will not focus editor with JTable content
    return;
  }

  setCurrentWindow(newWindow);
  setCurrentWindow(newWindow, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:EditorsSplitters.java

示例3: processContainerEvent

protected void processContainerEvent(ContainerEvent e) {
    // toolkit.lockAWT();
    // try {
    for (Iterator<?> i = containerListeners.getUserIterator(); i.hasNext();) {
        ContainerListener listener = (ContainerListener) i.next();

        switch (e.getID()) {
            case ContainerEvent.COMPONENT_ADDED:
                listener.componentAdded(e);
                break;
            case ContainerEvent.COMPONENT_REMOVED:
                listener.componentRemoved(e);
                break;
        }
    }
    // } finally {
    // toolkit.unlockAWT();
    // }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:Container.java

示例4: remove

public synchronized void remove(final Component comp) {
	if(components == null){
		return;
	}
	
	final int index = components.indexOf(comp);
	if (index >= 0) {
		components.remove(index);
		comp.parent = null;
		
		final ViewGroup layoutView = (ViewGroup)getContainerViewAdAPI();
		final View subView = comp.getPeerAdAPI();
		if(layoutView != null && subView != null){
			ActivityManager.getActivity().runOnUiThread(new Runnable() {
				@Override
				public void run() {
					layoutView.removeView(subView);
				}
			});
		}
		
		{
			final ContainerEvent event = new ContainerEvent(this, ContainerEvent.COMPONENT_REMOVED, comp);
			final ContainerListener[] listener = list.getListeners(ContainerListener.class);
			for (int i = 0; i < listener.length; i++) {
				listener[i].componentRemoved(event);
			}
		}
	}
	
	if (layout != null) {
		layout.removeLayoutComponent(comp);
	}
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:34,代码来源:Container.java

示例5: eventEnabled

boolean eventEnabled(AWTEvent e) {
    int id = e.getID();

    if (id == ContainerEvent.COMPONENT_ADDED ||
        id == ContainerEvent.COMPONENT_REMOVED) {
        if ((eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
            containerListener != null) {
            return true;
        }
        return false;
    }
    return super.eventEnabled(e);
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:13,代码来源:Container.java

示例6: eventDispatched

@Override
public void eventDispatched(AWTEvent event) {
	if (event instanceof MouseEvent) {
		MouseEvent me = (MouseEvent) event;
		if ((me.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
			Component deepest = SwingUtilities.getDeepestComponentAt(
					me.getComponent(), me.getX(), me.getY());
			setDisplayedComponent(deepest);
		}
	} else if (event instanceof ContainerEvent) {
		ContainerEvent ce = (ContainerEvent) event;
		if (ce.getID() == ContainerEvent.COMPONENT_ADDED) {
			stackTraces.put(ce.getChild(), new RuntimeException().getStackTrace());
		} else if (ce.getID() == ContainerEvent.COMPONENT_REMOVED) {
			stackTraces.remove(ce.getChild());
		}
	} else if (event instanceof KeyEvent) {
		KeyEvent ke = (KeyEvent) event;
		if (ke.getKeyCode() == KeyEvent.VK_D && (ke.getModifiersEx()
				& (InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)) != 0) {
			Window window = SwingUtilities.getWindowAncestor(ke.getComponent());
			if (window instanceof JDialog) {
				JDialog dialog = (JDialog) window;
				dialog.setModal(false);
				dialog.setVisible(false);
				dialog.setVisible(true);
			}
		}
	}
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:30,代码来源:SwingInspector.java

示例7: focusedComponentChanged

protected void focusedComponentChanged(final Component component, final AWTEvent cause) {
  EditorWindow newWindow = null;

  if (component != null) {
    newWindow = findWindowWith(component);
  }
  else if (cause instanceof ContainerEvent && cause.getID() == ContainerEvent.COMPONENT_REMOVED) {
    // do not change current window in case of child removal as in JTable.removeEditor
    // otherwise Escape in a toolwindow will not focus editor with JTable content
    return;
  }

  setCurrentWindow(newWindow);
  setCurrentWindow(newWindow, false);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:EditorsSplitters.java

示例8: remove

/**
 * Removes the component at the specified index from this container.
 *
 * @param index The index of the component to remove.
 */
public void remove(int index)
{
  synchronized (getTreeLock ())
    {
      if (index < 0 || index >= ncomponents)
        throw new ArrayIndexOutOfBoundsException();

      Component r = component[index];
      if (peer != null)
        r.removeNotify();

      if (layoutMgr != null)
        layoutMgr.removeLayoutComponent(r);

      // Update the counter for Hierarchy(Bounds)Listeners.
      int childHierarchyListeners = r.numHierarchyListeners;
      if (childHierarchyListeners > 0)
        updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
                                     -childHierarchyListeners);
      int childHierarchyBoundsListeners = r.numHierarchyBoundsListeners;
      if (childHierarchyBoundsListeners > 0)
        updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
                                     -childHierarchyListeners);

      r.parent = null;

      System.arraycopy(component, index + 1, component, index,
                       ncomponents - index - 1);
      component[--ncomponents] = null;

      if (valid)
        invalidate();

      if (containerListener != null
          || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)
        {
          // Post event to notify of removing the component.
          ContainerEvent ce = new ContainerEvent(this,
                                            ContainerEvent.COMPONENT_REMOVED,
                                            r);
          dispatchEvent(ce);
        }

      // Notify hierarchy listeners.
      r.fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, r,
                           this, HierarchyEvent.PARENT_CHANGED);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:53,代码来源:Container.java

示例9: removeAll

/**
 * Removes all components from this container.
 */
public void removeAll()
{
  synchronized (getTreeLock ())
    {
      // In order to allow the same bad tricks to be used as in RI
      // this code has to stay exactly that way: In a real-life app
      // a Container subclass implemented its own vector for
      // subcomponents, supplied additional addXYZ() methods
      // and overrode remove(int) and removeAll (the latter calling
      // super.removeAll() ).
      // By doing it this way, user code cannot prevent the correct
      // removal of components.
      while (ncomponents > 0)
        {
          ncomponents--;
          Component r = component[ncomponents];
          component[ncomponents] = null;

          if (peer != null)
            r.removeNotify();

          if (layoutMgr != null)
            layoutMgr.removeLayoutComponent(r);

          r.parent = null;

          // Send ContainerEvent if necessary.
          if (containerListener != null
              || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)
            {
              // Post event to notify of removing the component.
              ContainerEvent ce
                = new ContainerEvent(this,
                                     ContainerEvent.COMPONENT_REMOVED,
                                     r);
              dispatchEvent(ce);
            }

          // Update the counter for Hierarchy(Bounds)Listeners.
          int childHierarchyListeners = r.numHierarchyListeners;
          if (childHierarchyListeners > 0)
            updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
                                         -childHierarchyListeners);
          int childHierarchyBoundsListeners = r.numHierarchyBoundsListeners;
          if (childHierarchyBoundsListeners > 0)
            updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
                                         -childHierarchyListeners);


          // Send HierarchyEvent if necessary.
          fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, r, this,
                             HierarchyEvent.PARENT_CHANGED);

        }

      if (valid)
        invalidate();
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:62,代码来源:Container.java

示例10: removeDelicately

/**
 * Removes component comp from this container without making unneccessary changes
 * and generating unneccessary events. This function intended to perform optimized
 * remove, for example, if newParent and current parent are the same it just changes
 * index without calling removeNotify.
 * Note: Should be called while holding treeLock
 * @since: 1.5
 */
private void removeDelicately(Component comp, Container newParent, int newIndex) {
    checkTreeLock();

    int index = getComponentZOrder(comp);
    if (isRemoveNotifyNeeded(comp, this, newParent)) {                
        comp.removeNotify();
    }
    if (newParent != this) {
        if (layoutMgr != null) {
            layoutMgr.removeLayoutComponent(comp);
        }
        adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK, 
                                -comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
        adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
                                -comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
        adjustDescendants(-(comp.countHierarchyMembers()));

        comp.parent = null;
        System.arraycopy(component, index + 1,
                         component, index,
                         ncomponents - index - 1);
        component[--ncomponents] = null;

        if (valid) {
            invalidate();
        }
    } else {
        if (newIndex > index) { // 2->4: 012345 -> 013425, 2->5: 012345 -> 013452
            if (newIndex-index > 0) {
                System.arraycopy(component, index+1, component, index, newIndex-index);
            }
        } else { // 4->2: 012345 -> 014235
            if (index-newIndex > 0) {
                System.arraycopy(component, newIndex, component, newIndex+1, index-newIndex);
            }
        }
        component[newIndex] = comp;
    }
    if (comp.parent == null) { // was actually removed
        if (containerListener != null ||
            (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
            Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
            ContainerEvent e = new ContainerEvent(this, 
                                                  ContainerEvent.COMPONENT_REMOVED,
                                                  comp);
            dispatchEvent(e);

        }
        comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, comp,
                                   this, HierarchyEvent.PARENT_CHANGED,
                                   Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
        if (peer != null && layoutMgr == null && isVisible()) {
            updateCursorImmediately();
        }
    }
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:64,代码来源:Container.java

示例11: remove

/** 
    * Removes the component, specified by <code>index</code>, 
    * from this container. 
    * This method also notifies the layout manager to remove the
    * component from this container's layout via the
    * <code>removeLayoutComponent</code> method.
    *
    * <p>
    * Note: If a component has been removed from a container that
    * had been displayed, {@link #validate} must be
    * called on that container to reflect changes.
    * If multiple components are being removed, you can improve
    * efficiency by calling {@link #validate} only once,
    * after all the components have been removed.
    *
    * @param     index   the index of the component to be removed
    * @throws ArrayIndexOutOfBoundsException if {@code index} is not in
    *         range {@code [0, getComponentCount()-1]}
    * @see #add
    * @see #validate
    * @see #getComponentCount
    * @since JDK1.1
    */
   public void remove(int index) {
synchronized (getTreeLock()) {
           if (index < 0  || index >= ncomponents) {
               throw new ArrayIndexOutOfBoundsException(index);
           }
   	    Component comp = component[index];
    if (peer != null) {
	comp.removeNotify();
    }
    if (layoutMgr != null) {
	layoutMgr.removeLayoutComponent(comp);
    }

    adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK, 
        -comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
    adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
	-comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
           adjustDescendants(-(comp.countHierarchyMembers()));

    comp.parent = null;
    System.arraycopy(component, index + 1,
		     component, index,
		     ncomponents - index - 1);
    component[--ncomponents] = null;

    if (valid) {
	invalidate();
    }
           if (containerListener != null ||
               (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
               Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
               ContainerEvent e = new ContainerEvent(this, 
                                    ContainerEvent.COMPONENT_REMOVED,
                                    comp);
               dispatchEvent(e);
           }

    comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, comp,
			       this, HierarchyEvent.PARENT_CHANGED,
                                      Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
    if (peer != null && layoutMgr == null && isVisible()) {
               updateCursorImmediately();
    }
}
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:68,代码来源:Container.java

示例12: removeAll

/** 
    * Removes all the components from this container.
    * This method also notifies the layout manager to remove the
    * components from this container's layout via the
    * <code>removeLayoutComponent</code> method.
    * @see #add
    * @see #remove
    */
   public void removeAll() {
synchronized (getTreeLock()) {
    adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
                                   -listeningChildren);
    adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
	                    -listeningBoundsChildren);
           adjustDescendants(-descendantsCount);

    while (ncomponents > 0) {
	Component comp = component[--ncomponents];
	component[ncomponents] = null;

	if (peer != null) {
	    comp.removeNotify();
	}
	if (layoutMgr != null) {
	    layoutMgr.removeLayoutComponent(comp);
	}
	comp.parent = null;
               if (containerListener != null ||
                  (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
                   Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
                   ContainerEvent e = new ContainerEvent(this, 
                                    ContainerEvent.COMPONENT_REMOVED,
                                    comp);
                   dispatchEvent(e);
               }

	comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED,
				   comp, this,
				   HierarchyEvent.PARENT_CHANGED,
                                          Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
    }
    if (peer != null && layoutMgr == null && isVisible()) {
               updateCursorImmediately();
    }
    if (valid) {
	invalidate();
    }
}
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:49,代码来源:Container.java

示例13: processContainerEvent

/** 
 * Processes container events occurring on this container by
 * dispatching them to any registered ContainerListener objects.
 * NOTE: This method will not be called unless container events
 * are enabled for this component; this happens when one of the
 * following occurs:
 * <ul>
 * <li>A ContainerListener object is registered via
 *     <code>addContainerListener</code>
 * <li>Container events are enabled via <code>enableEvents</code>
 * </ul>
 * <p>Note that if the event parameter is <code>null</code>
 * the behavior is unspecified and may result in an
 * exception.
 *
 * @param e the container event
 * @see Component#enableEvents
 */  
protected void processContainerEvent(ContainerEvent e) {
    ContainerListener listener = containerListener;
    if (listener != null) {
        switch(e.getID()) {
          case ContainerEvent.COMPONENT_ADDED:
            listener.componentAdded(e);
            break;
          case ContainerEvent.COMPONENT_REMOVED:
            listener.componentRemoved(e);
            break;
        }
    }
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:31,代码来源:Container.java


注:本文中的java.awt.event.ContainerEvent.COMPONENT_REMOVED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。