List of usage examples for java.awt.event HierarchyEvent DISPLAYABILITY_CHANGED
int DISPLAYABILITY_CHANGED
To view the source code for java.awt.event HierarchyEvent DISPLAYABILITY_CHANGED.
Click Source Link
From source file:Main.java
@Override public void hierarchyChanged(HierarchyEvent e) { System.out.println("Components Change: " + e.getChanged()); if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) { if (e.getComponent().isDisplayable()) { System.out.println("Components DISPLAYABILITY_CHANGED : " + e.getChanged()); } else {/*from w w w.j a v a 2s. c o m*/ System.out.println("Components DISPLAYABILITY_CHANGED : " + e.getChanged()); } } if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { if (e.getComponent().isDisplayable()) { System.out.println("Components SHOWING_CHANGED : " + e.getChanged()); } else { System.out.println("Components SHOWING_CHANGED : " + e.getChanged()); } } }
From source file:com.mac.tarchan.desktop.event.EventQuery.java
/** * ???????????//from w ww .j a v a 2s . c om * * @param hierarchyChanged ? * @return ?? * @see <a href="http://terai.xrea.jp/Swing/DefaultFocus.html ">Window?????? - Java Swing Tips</a> * @see HierarchyListener#hierarchyChanged(HierarchyEvent) */ public EventQuery ready(final HierarchyListener hierarchyChanged) { for (Component child : list) { child.addHierarchyListener(new HierarchyListener() { public void hierarchyChanged(HierarchyEvent e) { if (e.getChangeFlags() == HierarchyEvent.DISPLAYABILITY_CHANGED) hierarchyChanged.hierarchyChanged(e); } }); } return this; }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopTabSheet.java
protected void detachTab(final int tabIndex) { final JComponent tabContent = (JComponent) impl.getComponentAt(tabIndex); TabImpl tabAtIndex = null;/*from ww w. j a v a 2 s .c o m*/ for (TabImpl tab : tabs) { if (DesktopComponentsHelper.getComposition(tab.getComponent()) == tabContent) { tabAtIndex = tab; if (tab.isLazy() && !tab.isLazyInitialized()) { initLazyTab(tabContent); } break; } } if (tabAtIndex == null) { throw new IllegalStateException("Unable to find tab to detach"); } final TabImpl tabToDetach = tabAtIndex; final ButtonTabComponent tabComponent = tabToDetach.getButtonTabComponent(); final JFrame frame = new DetachedFrame(tabComponent.getCaption(), impl); frame.setLocationRelativeTo(DesktopComponentsHelper.getTopLevelFrame(this)); impl.remove(tabContent); updateTabsEnabledState(); frame.setSize(impl.getSize()); frame.add(tabContent); final HierarchyListener listener = new HierarchyListener() { @Override public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) == HierarchyEvent.DISPLAYABILITY_CHANGED && !impl.isDisplayable()) { attachTab(frame, tabToDetach); impl.removeHierarchyListener(this); } } }; frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { attachTab(frame, tabToDetach); impl.removeHierarchyListener(listener); } }); impl.addHierarchyListener(listener); frame.setVisible(true); }