java.awt.event.HierarchyEvent#getChangeFlags()源码实例Demo

下面列出了java.awt.event.HierarchyEvent#getChangeFlags() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: darklaf   文件: DarkRootPaneUI.java
@Override
public void hierarchyChanged(final HierarchyEvent e) {
    if (rootPane == null) return;
    Component parent = rootPane.getParent();
    if (parent == null) {
        return;
    }
    if (parent.getClass().getName().startsWith("org.jdesktop.jdic.tray")
        || (parent.getClass().getName().equals("javax.swing.Popup$HeavyWeightWindow"))) {
        SwingUtilities.invokeLater(() -> {
            if (rootPane != null) {
                rootPane.removeHierarchyListener(this);
            }
        });
    }
    if (e.getChangeFlags() == HierarchyEvent.PARENT_CHANGED) {
        if (DarkUIUtil.getWindow(rootPane) != window) {
            updateClientDecoration();
        }
    }
}
 
源代码2 项目: dragonwell8_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();
}
 
源代码3 项目: JDKSourceCode1.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();
}
 
源代码4 项目: visualvm   文件: SamplerImpl.java
DataViewComponent.MasterView getMasterView() {
    initComponents();
    setState(State.INACTIVE);

    final HierarchyListener hl = new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (view.isShowing()) {
                    initializeCpuSampling();
                    initializeMemorySampling();
                    view.removeHierarchyListener(this);
                }
            }
        }
    };
    view.addHierarchyListener(hl);

    return new DataViewComponent.MasterView(NbBundle.getMessage(
               SamplerImpl.class, "LBL_Sampler"), null, view); // NOI18N
}
 
源代码5 项目: consulo   文件: UiNotifyConnector.java
@Override
public void hierarchyChanged(@Nonnull HierarchyEvent e) {
  if (isDisposed()) return;

  if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0) {
    final Runnable runnable = () -> {
      final Component c = myComponent.get();
      if (isDisposed() || c == null) return;

      if (c.isShowing()) {
        showNotify();
      }
      else {
        hideNotify();
      }
    };
    final Application app = ApplicationManager.getApplication();
    if (app != null && app.isDispatchThread()) {
      app.invokeLater(runnable, ModalityState.current());
    }
    else {
      //noinspection SSBasedInspection
      SwingUtilities.invokeLater(runnable);
    }
  }
}
 
源代码6 项目: openjdk-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();
}
 
源代码7 项目: visualvm   文件: Splitter.java
public void hierarchyChanged(HierarchyEvent e) {
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 ||
        (e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
        
        boolean visible = c.isVisible();
        if (wasVisible == visible) return;

        wasVisible = visible;

        if (visible) componentShown();
        else componentHidden(c);
    }
}
 
源代码8 项目: FlatLaf   文件: JBRCustomDecorations.java
static void install( JRootPane rootPane ) {
	if( !isSupported() )
		return;

	// check whether root pane already has a parent, which is the case when switching LaF
	if( rootPane.getParent() != null )
		return;

	// Use hierarchy listener to wait until the root pane is added to a window.
	// Enabling JBR decorations must be done very early, probably before
	// window becomes displayable (window.isDisplayable()). Tried also using
	// "ancestor" property change event on root pane, but this is invoked too late.
	HierarchyListener addListener = new HierarchyListener() {
		@Override
		public void hierarchyChanged( HierarchyEvent e ) {
			if( e.getChanged() != rootPane || (e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) == 0 )
				return;

			Container parent = e.getChangedParent();
			if( parent instanceof Window )
				install( (Window) parent );

			// use invokeLater to remove listener to avoid that listener
			// is removed while listener queue is processed
			EventQueue.invokeLater( () -> {
				rootPane.removeHierarchyListener( this );
			} );
		}
	};
	rootPane.addHierarchyListener( addListener );
}
 
源代码9 项目: rapidminer-studio   文件: IOObjectCacheViewer.java
@Override
public void hierarchyChanged(HierarchyEvent e) {
	// update whenever the component visibility changes, the view is dirty (prior updates
	// have been ignored), and not more than one update is scheduled
	synchronized (updateLock) {
		if ((HierarchyEvent.SHOWING_CHANGED & e.getChangeFlags()) != 0 && isDirty && scheduledUpdates <= 1) {
			scheduledUpdates++;
			SwingUtilities.invokeLater(updateEntries);
		}
	}
}
 
源代码10 项目: java-swing-tips   文件: MainPanel.java
@Override public void hierarchyChanged(HierarchyEvent e) {
  if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
    if (e.getComponent().isDisplayable()) {
      timer.start();
    } else {
      timer.stop();
    }
  }
}
 
源代码11 项目: visualvm   文件: VisibilityHandler.java
private HierarchyListener createListener() {
    return new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                boolean visible = component.isShowing();
                if (wasVisible == visible) return;

                wasVisible = visible;

                if (visible) shown();
                else hidden();
            }
        }
    };
}
 
源代码12 项目: weblaf   文件: AbstractDecorationPainter.java
/**
 * Informs about hierarchy changes.
 * Note that this method will only be fired when component {@link #usesHierarchyBasedView()}.
 *
 * @param event {@link HierarchyEvent}
 */
protected void hierarchyChanged ( @NotNull final HierarchyEvent event )
{
    // Ensure component is still available
    // This might happen if painter is replaced from another HierarchyListener
    if ( AbstractDecorationPainter.this.component != null )
    {
        // Listening only for parent change event
        // It will inform us when parent container for this component changes
        // Ancestor listener is not really reliable because it might inform about consequent parent changes
        if ( ( event.getChangeFlags () & HierarchyEvent.PARENT_CHANGED ) == HierarchyEvent.PARENT_CHANGED )
        {
            // If there was a previous container...
            if ( ancestor != null )
            {
                // Stop tracking neighbours
                ancestor.removeContainerListener ( neighboursTracker );
            }

            // Updating ancestor
            ancestor = AbstractDecorationPainter.this.component.getParent ();

            // If there is a new container...
            if ( ancestor != null )
            {
                // Start tracking neighbours
                ancestor.addContainerListener ( neighboursTracker );

                // Updating border
                updateBorder ();
            }
        }
    }
}
 
源代码13 项目: otroslogviewer   文件: TailLogActionListener.java
@Override
public void hierarchyChanged(HierarchyEvent e) {
  if (e.getChangeFlags() == 1 && e.getChanged().getParent() == null) {
    // if (e.getChangeFlags() == 6) {
    for (SoftReference<Stoppable> ref : referencesList) {
      Stoppable stoppable = ref.get();
      LOGGER.debug("Tab removed, stopping thread if reference is != null (actual: " + stoppable + ")");
      if (stoppable != null) {
        stoppable.stop();
      }
    }
  }

}
 
源代码14 项目: netbeans   文件: VisibilityHandler.java
private HierarchyListener createListener() {
    return new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                boolean visible = component.isShowing();
                if (wasVisible == visible) return;

                wasVisible = visible;

                if (visible) shown();
                else hidden();
            }
        }
    };
}
 
源代码15 项目: visualvm   文件: Splitter.java
public void hierarchyChanged(HierarchyEvent e) {
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 ||
        (e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
        
        boolean visible = c.isVisible();
        if (wasVisible == visible) return;

        wasVisible = visible;

        if (visible) componentShown();
        else componentHidden(c);
    }
}
 
源代码16 项目: netbeans   文件: FoldHierarchyExecution.java
@Override
public void hierarchyChanged(HierarchyEvent e) {
    if ((e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) == 0) {
        return;
    }
    // the component may be reparented, usually in the same execution sequence
    // within an event. Let's update (suspend or resume) the changes depending on
    // the stabilized state in a next AWT event:
    if (updating) {
        return;
    }
    updating = true;
    SwingUtilities.invokeLater(this);
}
 
源代码17 项目: visualvm   文件: JExtendedSplitPane.java
public void hierarchyChanged(HierarchyEvent e) {
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
        boolean visible = c.isVisible();
        if (wasVisible == visible) return;

        wasVisible = visible;

        if (visible) componentShown();
        else componentHidden(c);
    }
}
 
源代码18 项目: java-swing-tips   文件: MainPanel.java
@Override public void hierarchyChanged(HierarchyEvent e) {
  if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0 && !e.getComponent().isDisplayable()) {
    scroller.stop();
    scroller.removeActionListener(listener);
  }
}
 
源代码19 项目: java-swing-tips   文件: MainPanel.java
@Override public void hierarchyChanged(HierarchyEvent e) {
  if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0 && !e.getComponent().isDisplayable()) {
    animator.stop();
  }
}
 
源代码20 项目: java-swing-tips   文件: MainPanel.java
@Override public void hierarchyChanged(HierarchyEvent e) {
  if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0 && !e.getComponent().isDisplayable()) {
    inside.stop();
    outside.stop();
  }
}