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


Java ContainerEvent.COMPONENT_ADDED属性代码示例

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


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

示例3: 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

示例4: 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

示例5: addImpl

protected synchronized void addImpl(final Component comp, final Object constraints, final int index) {
		if(comp == this){
			throw new Error("add self to the container");
		}
		
		if (comp.parent != null) {
			comp.parent.remove(comp);
		}

		if(components == null){
			components = new java.util.ArrayList<Component>();
		}
		
		if (index == -1 || index > components.size()) {
			components.add(comp);
		} else {
			components.add(index, comp);
		}
		comp.parent = this;
		
		{
			final ContainerEvent event = new ContainerEvent(this, ContainerEvent.COMPONENT_ADDED, comp);
			final ContainerListener[] listener = list.getListeners(ContainerListener.class);
			for (int i = 0; i < listener.length; i++) {
				listener[i].componentAdded(event);
			}
		}

		if (layout != null) {
//			View subView = comp.getPeerAdAPI();
//			if(subView != null){
//				AbsoluteLayout.LayoutParams lp = new AbsoluteLayout.LayoutParams(0, 0, 0, 0);
//				layoutView.addView(subView, lp);
//			}
			
			if (layout instanceof LayoutManager2) {
				((LayoutManager2) layout).addLayoutComponent(comp, constraints);
			} else if (constraints instanceof String) {
				layout.addLayoutComponent((String) constraints, comp);
			}
		}
	}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:42,代码来源:Container.java

示例6: eventDispatched

@Override
public void eventDispatched(AWTEvent event) {
	if (event instanceof ContainerEvent) {
        ContainerEvent containerEvent = (ContainerEvent)event;
        if (containerEvent.getID() == ContainerEvent.COMPONENT_ADDED){
        	Component container = containerEvent.getChild();
        	if ((container instanceof JButton)||
        		(container instanceof JCheckBox)||
        		(container instanceof JComboBox)||
        		(container instanceof JLabel)||
        		(container instanceof JMenu)||
        		(container instanceof JMenuItem)||
        		(container instanceof JRadioButton)||
        		(container instanceof JRadioButtonMenuItem)||
        		(container instanceof JSpinner)||
        		(container instanceof JTabbedPane)||
        		(container instanceof JTextField)||
        		(container instanceof JHelp)||
        		(container instanceof JFileChooser)||
        		((container instanceof JScrollPane)&&(!(container instanceof CanvasPane)))||
        		(container instanceof JFontChooser)||
        		(container instanceof JCheckBoxMenuItem)) {
        		AppPreferences.setScaledFonts(((JComponent)container).getComponents());
        		try{container.setFont(AppPreferences.getScaledFont(containerEvent.getChild().getFont()));
        			container.revalidate();
        			container.repaint();}
        		catch(Exception e){}
        	}
        	if (container instanceof JOptionPane) {
        		JOptionPane pane = (JOptionPane) container;
        		if (HasIcon(pane)) {
        			ImageIcon icon;
        			switch (pane.getMessageType()) {
        				case JOptionPane.ERROR_MESSAGE :
        					icon = new ImageIcon(getClass().getClassLoader().getResource("resources/logisim/error.png"));
        					pane.setIcon(AppPreferences.getScaledImageIcon(icon,(float) 3));
        					break;
        				case JOptionPane.QUESTION_MESSAGE :
        					icon = new ImageIcon(getClass().getClassLoader().getResource("resources/logisim/question.png"));
        					pane.setIcon(AppPreferences.getScaledImageIcon(icon,(float) 3));
        					break;
        				case JOptionPane.PLAIN_MESSAGE :
        					icon = new ImageIcon(getClass().getClassLoader().getResource("resources/logisim/plain.png"));
        					pane.setIcon(AppPreferences.getScaledImageIcon(icon,(float) 3));
        					break;
        				case JOptionPane.INFORMATION_MESSAGE :
        					icon = new ImageIcon(getClass().getClassLoader().getResource("resources/logisim/info.png"));
        					pane.setIcon(AppPreferences.getScaledImageIcon(icon,(float) 3));
        					break;
        				case JOptionPane.WARNING_MESSAGE :
        					icon = new ImageIcon(getClass().getClassLoader().getResource("resources/logisim/warning.png"));
        					pane.setIcon(AppPreferences.getScaledImageIcon(icon,(float) 3));
        					break;
        			}
        		}
        	}
        }
		
	}
	// TODO Auto-generated method stub
	
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:62,代码来源:Startup.java

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