Java 类java.awt.event.HierarchyListener 实例源码

项目:incubator-netbeans    文件:OQLControllerUI.java   
public QueryUI(OQLController.QueryController queryController, OQLEngine engine) {
    super(Bundle.OQLControllerUI_QueryEditorCaption(), ICON, true);

    this.queryController = queryController;

    initComponents(engine);

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) {
                    updateUIState();
                    QueryUI.this.removeHierarchyListener(this);
                }
            }
        }
    });
}
项目:incubator-netbeans    文件:InstancesListControllerUI.java   
InstanceScrollPane(Heap heap) {
    this.heap = heap;

    setBorder(BorderFactory.createEmptyBorder());
    setViewportBorder(BorderFactory.createLineBorder(
            UIManager.getLookAndFeel().getID().equals("Metal") ? // NOI18N
            UIManager.getColor("Button.darkShadow") : // NOI18N
            UIManager.getColor("Button.shadow"))); // NOI18N

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (instancePending && isShowing()) showInstanceImpl();
            }
        }
    });
}
项目:incubator-netbeans    文件:JTreeTablePanel.java   
/** Creates a new instance of JTreeTablePanel */
public JTreeTablePanel(JTreeTable treeTable) {
    super(new BorderLayout());
    this.treeTable = treeTable;

    initComponents();
    hookHeaderColumnResize();
    hookScrollBarValueChange();
    hookTreeCollapsedExpanded();

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (isShowing()) {
                    updateScrollBar(true);
                }
            }
        }
    });
}
项目:VASSAL-src    文件:SpecialDiceButton.java   
/**
 * Expects to be added to a SymbolDice. Adds the button to the control window's toolbar and registers itself as a
 * {@link KeyStrokeListener}
 */
public void addTo(Buildable parent) {
  resultsIcon.setResults(new int[dice.size()]);
  launch.addHierarchyListener(new HierarchyListener() {
    public void hierarchyChanged(HierarchyEvent e) {
      if (launch.isShowing()) {
        dialog.setLocationRelativeTo(launch);
        launch.removeHierarchyListener(this);
      }
    }
  });
  final GameModule mod = GameModule.getGameModule();
  ran = mod.getRNG();
  mod.getToolBar().add(launch);
  idMgr.add(this);
  mod.addCommandEncoder(this);
  property.addTo((MutablePropertiesContainer)parent);
}
项目:JavaGraph    文件:GraphPreviewDialog.java   
/** Returns the main panel shown on this dialog. */
public GraphPreviewPanel getContent() {
    if (this.contentPanel == null) {
        this.contentPanel = new GraphPreviewPanel(getJGraph());
        this.contentPanel.initialise();
        this.contentPanel.setEnabled(true);
        // make any dialog in which this panel is embedded resizable
        // taken from https://blogs.oracle.com/scblog/entry/tip_making_joptionpane_dialog_resizable
        this.contentPanel.addHierarchyListener(new HierarchyListener() {
            @Override
            public void hierarchyChanged(HierarchyEvent e) {
                Window window =
                    SwingUtilities.getWindowAncestor(GraphPreviewDialog.this.contentPanel);
                if (window instanceof Dialog) {
                    Dialog dialog = (Dialog) window;
                    if (!dialog.isResizable()) {
                        dialog.setResizable(true);
                    }
                }
            }
        });
    }
    return this.contentPanel;
}
项目:OpenJSharp    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:jdk8u-jdk    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:openjdk-jdk10    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:openjdk9    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:PhET    文件:PCanvas.java   
/**
 * Construct a canvas with the basic scene graph consisting of a root,
 * camera, and layer. Zooming and panning are automatically installed.
 */
public PCanvas() {
    CURRENT_ZCANVAS = this;
    cursorStack = new PStack();
    setCamera(createDefaultCamera());
    setDefaultRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
    setAnimatingRenderQuality(PPaintContext.LOW_QUALITY_RENDERING);
    setInteractingRenderQuality(PPaintContext.LOW_QUALITY_RENDERING);
    setPanEventHandler(new PPanEventHandler());
    setZoomEventHandler(new PZoomEventHandler());
    setBackground(Color.WHITE);
    setOpaque(true);

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(final HierarchyEvent e) {
            if (e.getComponent() == PCanvas.this) {
                if (getParent() == null) {
                    removeInputSources();
                }
                else if (isEnabled()) {
                    installInputSources();
                }
            }
        }
    });
}
项目:jdk8u_jdk    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:littleluck    文件:BezierAnimationPanel.java   
/**
 * BezierAnimationPanel Constructor
 */
public BezierAnimationPanel() {
    setOpaque(true);

    colors.put(BACKGROUND, new Color(0, 0, 153));
    colors.put(OUTER, new Color(255, 255, 255));
    colors.put(GRADIENT_A, new Color(255, 0, 101));
    colors.put(GRADIENT_B, new Color(255, 255, 0));

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if (isShowing()) {
                start();
            } else {
                stop();
            }
        }
    }
    );
}
项目:lookaside_java-1.8.0-openjdk    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:cuba    文件:DetachedFrame.java   
private void initUI() {
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    glassPane = new DisabledGlassPane();
    JRootPane rootPane = SwingUtilities.getRootPane(this);
    rootPane.setGlassPane(glassPane);

    final java.awt.Component topLevelGlassPane = DesktopComponentsHelper.getTopLevelFrame(parentContainer).getGlassPane();
    topLevelGlassPane.addHierarchyListener(new HierarchyListener() {
        @Override
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) == HierarchyEvent.SHOWING_CHANGED) {
                if (topLevelGlassPane.isVisible()) {
                    glassPane.activate(null);
                } else {
                    glassPane.deactivate();
                }
            }
        }
    });
}
项目:javify    文件:Component.java   
/**
 * Adds the specified listener to this component. This is harmless if the
 * listener is null, but if the listener has already been registered, it
 * will now be registered twice.
 *
 * @param listener the new listener to add
 * @see HierarchyEvent
 * @see #removeHierarchyListener(HierarchyListener)
 * @see #getHierarchyListeners()
 * @since 1.3
 */
public synchronized void addHierarchyListener(HierarchyListener listener)
{
  if (listener != null)
    {
      hierarchyListener = AWTEventMulticaster.add(hierarchyListener,
                                                  listener);
      newEventsOnly = true;
      // Need to lock the tree, otherwise we might end up inconsistent.
      synchronized (getTreeLock())
      {
        numHierarchyListeners++;
        if (parent != null)
          parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
                                              1);
      }
    }
}
项目:triplea    文件:PbemSetupPanel.java   
private void createComponents() {
  final JScrollPane scrollPane = new JScrollPane(localPlayerPanel);
  localPlayerPanel.addHierarchyListener(new HierarchyListener() {
    @Override
    public void hierarchyChanged(final HierarchyEvent e) {
      final Window window = SwingUtilities.getWindowAncestor(localPlayerPanel);
      if (window instanceof Dialog) {
        final Dialog dialog = (Dialog) window;
        if (!dialog.isResizable()) {
          dialog.setResizable(true);
          dialog.setMinimumSize(new Dimension(700, 700));
        }
      }
    }
  });
  localPlayerSelection.addActionListener(
      e -> JOptionPane.showMessageDialog(PbemSetupPanel.this, scrollPane, "Select Local Players and AI's",
          JOptionPane.PLAIN_MESSAGE));
}
项目:beautyeye    文件:BezierAnimationPanel.java   
/**
 * BezierAnimationPanel Constructor
 */
public BezierAnimationPanel() {
    setOpaque(true);

    colors.put(BACKGROUND, new Color(0, 0, 153));
    colors.put(OUTER, new Color(255, 255, 255));
    colors.put(GRADIENT_A, new Color(255, 0, 101));
    colors.put(GRADIENT_B, new Color(255, 255, 0));

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if (isShowing()) {
                start();
            } else {
                stop();
            }
        }
    }
    );
}
项目:jvm-stm    文件:Component.java   
/**
 * Adds the specified listener to this component. This is harmless if the
 * listener is null, but if the listener has already been registered, it
 * will now be registered twice.
 *
 * @param listener the new listener to add
 * @see HierarchyEvent
 * @see #removeHierarchyListener(HierarchyListener)
 * @see #getHierarchyListeners()
 * @since 1.3
 */
public synchronized void addHierarchyListener(HierarchyListener listener)
{
  if (listener != null)
    {
      hierarchyListener = AWTEventMulticaster.add(hierarchyListener,
                                                  listener);
      newEventsOnly = true;
      // Need to lock the tree, otherwise we might end up inconsistent.
      synchronized (getTreeLock())
      {
        numHierarchyListeners++;
        if (parent != null)
          parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
                                              1);
      }
    }
}
项目:netbeans-mmd-plugin    文件:UiUtils.java   
public static void makeOwningDialogResizable(@Nonnull final Component component, @Nonnull @MustNotContainNull final Runnable... extraActions) {
  final HierarchyListener listener = new HierarchyListener() {
    @Override
    public void hierarchyChanged(@Nonnull final HierarchyEvent e) {
      final Window window = SwingUtilities.getWindowAncestor(component);
      if (window instanceof Dialog) {
        final Dialog dialog = (Dialog) window;
        if (!dialog.isResizable()) {
          dialog.setResizable(true);
          component.removeHierarchyListener(this);

          for (final Runnable r : extraActions) {
            r.run();
          }
        }
      }
    }
  };
  component.addHierarchyListener(listener);
}
项目:metasfresh    文件:CTable.java   
private final HierarchyListener createHierarchyListener()
{
    return new HierarchyListener()
    {

        @Override
        public void hierarchyChanged(HierarchyEvent e)
        {
            if (e.getChangeFlags() == HierarchyEvent.PARENT_CHANGED)
            {
                configureColumnControl();
            }
        }

    };
}
项目:CommandGenerator    文件:Tag.java   
/** Displays the Tag panel. Returns true if the user canceled. */
protected boolean showPanel()
{
    isEmpty = true;

    panel.addHierarchyListener(new HierarchyListener() {
        @Override
        public void hierarchyChanged(HierarchyEvent e)
        {
            Window window = SwingUtilities.getWindowAncestor(panel);
            if (window instanceof Dialog)
            {
                Dialog dialog = (Dialog) window;
                if (!dialog.isResizable())
                {
                    dialog.setResizable(true);
                }
            }
        }
    });
    boolean cancel = JOptionPane.showConfirmDialog(null, panel, Generator.translate("GUI:tag.add") + " : " + getName(), JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION;
    if (!cancel) isEmpty = false;
    return cancel;
}
项目:piccolo2d.java    文件:PCanvas.java   
/**
 * Construct a canvas with the basic scene graph consisting of a root,
 * camera, and layer. Zooming and panning are automatically installed.
 */
public PCanvas() {
    cursorStack = new PStack();
    setCamera(createDefaultCamera());
    setDefaultRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
    setAnimatingRenderQuality(PPaintContext.LOW_QUALITY_RENDERING);
    setInteractingRenderQuality(PPaintContext.LOW_QUALITY_RENDERING);
    setPanEventHandler(new PPanEventHandler());
    setZoomEventHandler(new PZoomEventHandler());
    setBackground(Color.WHITE);
    setOpaque(true);

    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(final HierarchyEvent e) {
            if (e.getComponent() == PCanvas.this) {
                if (getParent() == null) {
                    removeInputSources();
                }
                else if (isEnabled()) {
                    installInputSources();
                }
            }
        }
    });
}
项目:infobip-open-jdk-8    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:jdk8u-dev-jdk    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:vassal    文件:SpecialDiceButton.java   
/**
 * Expects to be added to a SymbolDice. Adds the button to the control window's toolbar and registers itself as a
 * {@link KeyStrokeListener}
 */
public void addTo(Buildable parent) {
  resultsIcon.setResults(new int[dice.size()]);
  launch.addHierarchyListener(new HierarchyListener() {
    public void hierarchyChanged(HierarchyEvent e) {
      if (launch.isShowing()) {
        dialog.setLocationRelativeTo(launch);
        launch.removeHierarchyListener(this);
      }
    }
  });
  final GameModule mod = GameModule.getGameModule();
  ran = mod.getRNG();
  mod.getToolBar().add(launch);
  idMgr.add(this);
  mod.addCommandEncoder(this);
  property.addTo((MutablePropertiesContainer)parent);
}
项目:jo-widgets    文件:SwingDisposeObservable.java   
public SwingDisposeObservable(final Component component) {
    Assert.paramNotNull(component, "component");

    this.wasDisplayable = component.isDisplayable();
    component.addHierarchyListener(new HierarchyListener() {
        @Override
        public void hierarchyChanged(final HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                if (wasDisplayable && !component.isDisplayable()) {
                    fireAfterDispose();
                }
                else if (!wasDisplayable && component.isDisplayable()) {
                    wasDisplayable = true;
                }
            }
        }
    });
}
项目:jdk7-jdk    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:openjdk-source-code-learn    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:OLD-OpenJDK8    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:cn1    文件:Component.java   
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}
项目:cn1    文件:BasicInternalFrameTitlePane.java   
protected void installListeners() {
    if (propertyChangeListener == null) {
        propertyChangeListener = createPropertyChangeListener();
    }
    frame.addPropertyChangeListener(propertyChangeListener);

    // propertyChangeListener will be uninstalled
    // when title pane is removed from internal frame
    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(final HierarchyEvent e) {
            if (e.getChanged() == BasicInternalFrameTitlePane.this
                    && (e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) != 0
                    && !frame.isAncestorOf(BasicInternalFrameTitlePane.this)) {
                uninstallListeners();
            }
        }
    });
}
项目:JamVM-PH    文件:Component.java   
/**
 * Adds the specified listener to this component. This is harmless if the
 * listener is null, but if the listener has already been registered, it
 * will now be registered twice.
 *
 * @param listener the new listener to add
 * @see HierarchyEvent
 * @see #removeHierarchyListener(HierarchyListener)
 * @see #getHierarchyListeners()
 * @since 1.3
 */
public synchronized void addHierarchyListener(HierarchyListener listener)
{
  if (listener != null)
    {
      hierarchyListener = AWTEventMulticaster.add(hierarchyListener,
                                                  listener);
      newEventsOnly = true;
      // Need to lock the tree, otherwise we might end up inconsistent.
      synchronized (getTreeLock())
      {
        numHierarchyListeners++;
        if (parent != null)
          parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
                                              1);
      }
    }
}
项目:UiL-OTS-Video-Coding-System    文件:VLCMediaPlayer.java   
private void internalCreateNewVisualComponent(String [] prepareOptions) {
       playerComponent = new EmbeddedMediaPlayerComponent();
       player = playerComponent.getMediaPlayer();
       player.addMediaPlayerEventListener(infoListener);

       playerComponent.addHierarchyListener(new HierarchyListener() {
        // This makes sure that when the player window becomes displayable
        // (which is a subset of visible) the player shows some frame in it. 
        // This can't be done before that time.
           public void hierarchyChanged(HierarchyEvent e) {
            long flags = e.getChangeFlags() & (HierarchyEvent.PARENT_CHANGED);
               if ((flags != 0) &&  e.getComponent().isDisplayable()) {
                   player.start();
                    player.pause();
            }
           }
       });

       // configure the player with the given media file
       player.prepareMedia(mediaURL, prepareOptions);
       player.parseMedia();

       player.setEnableMouseInputHandling(false);
       player.setEnableKeyInputHandling(false);
}
项目:openjdk-jdk7u-jdk    文件:WindowsMenuBarUI.java   
@Override
protected void installListeners() {
    if (WindowsLookAndFeel.isOnVista()) {
        installWindowListener();
        hierarchyListener =
            new HierarchyListener() {
                public void hierarchyChanged(HierarchyEvent e) {
                    if ((e.getChangeFlags()
                            & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
                        if (menuBar.isDisplayable()) {
                            installWindowListener();
                        } else {
                            uninstallWindowListener();
                        }
                    }
                }
        };
        menuBar.addHierarchyListener(hierarchyListener);
    }
    super.installListeners();
}
项目:wandora    文件:ProcessingTopicPanel.java   
private void showRichErrorDialog(String msg) {
final JTextArea area = new JTextArea();
area.setFont(errorMessageFont);
//area.setPreferredSize(new Dimension(520, 180));
area.setEditable(false);
area.setText(msg);

// Make the JOptionPane resizable using the HierarchyListener
       area.addHierarchyListener(new HierarchyListener() {
           public void hierarchyChanged(HierarchyEvent e) {
               Window window = SwingUtilities.getWindowAncestor(area);
               if (window instanceof Dialog) {
                   Dialog dialog = (Dialog)window;
                   if (!dialog.isResizable()) {
                       dialog.setResizable(true);
                   }
               }
           }
       });

JScrollPane scroller = new JScrollPane(area);
scroller.setPreferredSize(new Dimension(520, 180));
JOptionPane.showMessageDialog(Wandora.getWandora(), scroller, "Errors", JOptionPane.PLAIN_MESSAGE);
   }
项目:classpath    文件:Component.java   
/**
 * Adds the specified listener to this component. This is harmless if the
 * listener is null, but if the listener has already been registered, it
 * will now be registered twice.
 *
 * @param listener the new listener to add
 * @see HierarchyEvent
 * @see #removeHierarchyListener(HierarchyListener)
 * @see #getHierarchyListeners()
 * @since 1.3
 */
public synchronized void addHierarchyListener(HierarchyListener listener)
{
  if (listener != null)
    {
      hierarchyListener = AWTEventMulticaster.add(hierarchyListener,
                                                  listener);
      newEventsOnly = true;
      // Need to lock the tree, otherwise we might end up inconsistent.
      synchronized (getTreeLock())
      {
        numHierarchyListeners++;
        if (parent != null)
          parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
                                              1);
      }
    }
}
项目:freeVM    文件:Component.java   
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}
项目:freeVM    文件:BasicInternalFrameTitlePane.java   
protected void installListeners() {
    if (propertyChangeListener == null) {
        propertyChangeListener = createPropertyChangeListener();
    }
    frame.addPropertyChangeListener(propertyChangeListener);

    // propertyChangeListener will be uninstalled
    // when title pane is removed from internal frame
    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(final HierarchyEvent e) {
            if (e.getChanged() == BasicInternalFrameTitlePane.this
                    && (e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) != 0
                    && !frame.isAncestorOf(BasicInternalFrameTitlePane.this)) {
                uninstallListeners();
            }
        }
    });
}
项目:freeVM    文件:Component.java   
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}
项目:freeVM    文件:BasicInternalFrameTitlePane.java   
protected void installListeners() {
    if (propertyChangeListener == null) {
        propertyChangeListener = createPropertyChangeListener();
    }
    frame.addPropertyChangeListener(propertyChangeListener);

    // propertyChangeListener will be uninstalled
    // when title pane is removed from internal frame
    addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(final HierarchyEvent e) {
            if (e.getChanged() == BasicInternalFrameTitlePane.this
                    && (e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) != 0
                    && !frame.isAncestorOf(BasicInternalFrameTitlePane.this)) {
                uninstallListeners();
            }
        }
    });
}