本文整理汇总了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;
}
}
示例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();
// }
}
示例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);
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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
}
示例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;
}
}
}