Java Code Examples for java.awt.event.HierarchyEvent#SHOWING_CHANGED

The following examples show how to use java.awt.event.HierarchyEvent#SHOWING_CHANGED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultTabbedContainerUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void hierarchyChanged(HierarchyEvent e) {
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
        boolean showing = container.isShowing();
        if (showing != bug4924561knownShowing) {
            if (container.isShowing()) {
                initDisplayer();
                attachModelAndSelectionListeners();
                ensureSelectedComponentIsShowing();
                if (container.getType() == TabbedContainer.TYPE_SLIDING) {
                    updateOrientation();
                }
            } else {
                detachModelAndSelectionListeners();
                if (container.getType() == TabbedContainer.TYPE_SLIDING) {
                    updateOrientation();
                }
            }
        }
        bug4924561knownShowing = showing;
    }
}
 
Example 2
Source File: JHTMLBundle.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void hierarchyChanged(HierarchyEvent e) {
  if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
    // This pane has changed show-state.
    if (isShowing()) {
      // on screen: Clear history.
      historyBack.clear();
      historyCurrent = null;
      historyFwd.clear();
      alignHistoryButtonEnableState();
      if (SwingUtilities.isEventDispatchThread()) {
        new ValueUpdater().run();
      } else {
        // Views are not updated when not showing; schedule a call to
        // updateView()
        currentUpdater = new ValueUpdater();
        SwingUtilities.invokeLater(currentUpdater);
      }
    }
  }
}
 
Example 3
Source File: SwingSet3.java    From littleluck with Apache License 2.0 6 votes vote down vote up
public void hierarchyChanged(HierarchyEvent event) {
    if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0) {
        JComponent component = (JComponent)event.getComponent();
        final Demo demo = (Demo)component.getClientProperty("swingset3.demo");
        if (!component.isShowing()) {
            demo.stop();
        } else {
            demoContainer.revalidate();
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    demo.start();
                }
            });
        }
    }            
}
 
Example 4
Source File: UiNotifyConnector.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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);
    }
  }
}
 
Example 5
Source File: SwingSet3.java    From Darcula with Apache License 2.0 6 votes vote down vote up
public void hierarchyChanged(HierarchyEvent event) {
    if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0) {
        JComponent component = (JComponent)event.getComponent();
        final Demo demo = (Demo)component.getClientProperty("swingset3.demo");
        if (!component.isShowing()) {
            demo.stop();
        } else {
            demoContainer.revalidate();
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    demo.start();
                }
            });
        }
    }            
}
 
Example 6
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
@Override public void updateUI() {
  removeHierarchyListener(listener);
  super.updateUI();
  listener = e -> {
    Component c = e.getComponent();
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && c.isShowing()) {
      // Component w = SwingUtilities.getRoot(c);
      // if (w instanceof JWindow) {
      //   System.out.println("Popup$HeavyWeightWindow");
      //   w.setBackground(new Color(0x0, true));
      // }
      Optional.ofNullable(SwingUtilities.getRoot(c))
          .filter(JWindow.class::isInstance).map(JWindow.class::cast)
          .ifPresent(w -> w.setBackground(new Color(0x0, true)));
    }
  };
  addHierarchyListener(listener);
  setOpaque(false);
  setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 5));
}
 
Example 7
Source File: Splitter.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example 8
Source File: BufferedCanvasComponent.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void hierarchyChanged(HierarchyEvent e) {
    if ((e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) != 0) {
        Window parentWindow = SwingUtilities.getWindowAncestor(BufferedCanvasComponent.this);
        if (lastParentWindow != parentWindow) {
            if (lastParentWindow != null) lastParentWindow.removeWindowListener(VisibilityHandler.this);
            if (parentWindow != null) parentWindow.addWindowListener(VisibilityHandler.this);
            lastParentWindow = parentWindow;
        }
    }
    
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
        if (isShowing()) BufferedCanvasComponent.this.shown();
        else BufferedCanvasComponent.this.hidden();
    }
}
 
Example 9
Source File: VisibilityHandler.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
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();
            }
        }
    };
}
 
Example 10
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
@Override public void hierarchyChanged(HierarchyEvent e) {
  if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
    JLabel l = (JLabel) e.getComponent();
    if (l.isShowing()) {
      // LOGGER.info(() -> "isShowing=true");
      atomicDown.set(SECONDS);
      l.setText(String.format("Closing in %d seconds", SECONDS));
      timer.removeActionListener(listener);
      listener = event -> {
        int i = atomicDown.decrementAndGet();
        l.setText(String.format("Closing in %d seconds", i));
        if (i <= 0 && timer.isRunning()) {
          // LOGGER.info(() -> "Timer: timer.stop()");
          timer.stop();
          Optional.ofNullable(l.getTopLevelAncestor())
              .filter(Window.class::isInstance).map(Window.class::cast)
              .ifPresent(Window::dispose);
          // Container c = l.getTopLevelAncestor();
          // if (c instanceof Window) {
          //   // LOGGER.info(() -> "window.dispose()");
          //   ((Window) c).dispose();
          // }
        }
      };
      timer.addActionListener(listener);
      timer.start();
    } else {
      // LOGGER.info(() -> "isShowing=false");
      if (timer.isRunning()) {
        // LOGGER.info(() -> "timer.stop()");
        timer.stop();
      }
    }
  }
}
 
Example 11
Source File: VisibilityHandler.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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();
            }
        }
    };
}
 
Example 12
Source File: SystemTimeList.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
@Override
public void hierarchyChanged(HierarchyEvent e) {
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
        if (e.getChanged().isVisible()) {
            gui.addPropertyChangeListener("timeZone", this);
            gui.addDataSetListener((SystemTimeTableModel) systemTimes.getModel());
        }
        else {
            gui.removePropertyChangeListener("timeZone", this);
            gui.removeDataSetListener((SystemTimeTableModel) systemTimes.getModel());
        }
    }
}
 
Example 13
Source File: JExtendedSplitPane.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example 14
Source File: IntervalList.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
@Override
public void hierarchyChanged(HierarchyEvent e) {
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
        if (e.getChanged().isVisible()) {
            gui.addPropertyChangeListener("timeZone", this);
            gui.getIntervalManager().addListener((IntervalTableModel) intervals.getModel());
        }
        else {
            gui.removePropertyChangeListener("timeZone", this);
            gui.getIntervalManager().removeListener((IntervalTableModel) intervals.getModel());
        }
    }
}
 
Example 15
Source File: JExtendedSplitPane.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example 16
Source File: LocationCustomizer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void hierarchyChanged(HierarchyEvent e) {
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
        Window window = SwingUtilities.getWindowAncestor(this);

        if (window instanceof Dialog && !((Dialog) window).isModal()) {
            showFromEditor();
        } else {
            hideFromEditor();
        }
    }
}
 
Example 17
Source File: IOObjectCacheViewer.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@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);
		}
	}
}
 
Example 18
Source File: ListHoverHelper.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void hierarchyChanged(HierarchyEvent e) {
	if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
		if (!list.isShowing()) {
			lastLocation = null;
			setHoverIndex(-1);
		}
		// else: nothing to be done as mouse location is not known (only 1.5)
	}
}
 
Example 19
Source File: WizardCardLayout.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
/**
 * <p>Keeps track of the current card</p>
 *
 * @param e The event
 */
@Override
public void hierarchyChanged(HierarchyEvent e) {
    JComponent component = (JComponent) e.getSource();

    if ((HierarchyEvent.SHOWING_CHANGED & e.getChangeFlags()) != 0
            && component.isShowing()) {
        currentCard = component;

    }
}
 
Example 20
Source File: EditorView.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void hierarchyChanged(HierarchyEvent e) {
  if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && e.getComponent().isShowing()) {
    checkFontRenderContext(null);
  }
}