List of usage examples for java.awt.event HierarchyEvent getComponent
public Component getComponent()
From source file:Main.java
public static void onShown(final JComponent component, final Runnable action) { component.addHierarchyListener(new HierarchyListener() { public void hierarchyChanged(final HierarchyEvent e) { if (e.getComponent() == component && (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0) { if (component.isShowing()) action.run();//from www . j av a 2 s.c o m } } }); }
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. ja v a 2s . co 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:edu.uara.gui.tableeditor.ChartGenerationFrame.java
private void panelAncestorResized(java.awt.event.HierarchyEvent evt) { //handle resize // Component parent = evt.getChangedParent(); Component parent = this.splitPane; Component comp = evt.getComponent(); if (comp != null && parent != null) { comp.setSize(parent.getWidth(), this.splitPane.getDividerLocation()); String s = String.format("Current Width = %1$s" + " Height = %2$s", comp.getWidth(), comp.getHeight()); this.updateStatus(s); }/*from w ww . ja v a 2 s . co m*/ }