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

项目:swingx    文件:JXLabel.java   
/**
 * Helper method for initializing multi line support.
 */
private void initLineWrapSupport() {
    addPropertyChangeListener(new MultiLineSupport());
    // FYI: no more listening for componentResized. Those events are delivered out
    // of order and without old values are meaningless and forcing us to react when
    // not necessary. Instead overriding reshape() ensures we have control over old AND new size.
    addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
        @Override
        public void ancestorResized(HierarchyEvent e) {
            // if one of the parents is viewport, resized events will not be propagated down unless viewport is changing visibility of scrollbars.
            // To make sure Label is able to re-wrap text when viewport size changes, initiate re-wrapping here by changing size of view
            if (e.getChanged() instanceof JViewport) {
                Rectangle viewportBounds = e.getChanged().getBounds();
                if (viewportBounds.getWidth() < getWidth()) {
                    View view = getWrappingView();
                    if (view != null) {
                        view.setSize(viewportBounds.width, viewportBounds.height);
                    }
                }
            }
        }});
}
项目:aibench-project    文件:JXLabel.java   
/**
 * Helper method for initializing multi line support.
 */
private void initLineWrapSupport() {
    addPropertyChangeListener(new MultiLineSupport());
    // FYI: no more listening for componentResized. Those events are delivered out
    // of order and without old values are meaningless and forcing us to react when
    // not necessary. Instead overriding reshape() ensures we have control over old AND new size.
    addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
        public void ancestorResized(HierarchyEvent e) {
            // if one of the parents is viewport, resized events will not be propagated down unless viewport is changing visibility of scrollbars.
            // To make sure Label is able to re-wrap text when viewport size changes, initiate re-wrapping here by changing size of view
            if (e.getChanged() instanceof JViewport) {
                Rectangle viewportBounds = e.getChanged().getBounds();
                if (viewportBounds.getWidth() < getWidth()) {
                    View view = getWrappingView();
                    if (view != null) {
                        view.setSize(viewportBounds.width, viewportBounds.height);
                    }
                }
            }
        }});
}
项目:ca-iris    文件:ScreenLayout.java   
/** Create a new screen layout manager */
public ScreenLayout(final Container parent) {
    parent.addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
        public void ancestorMoved(HierarchyEvent e) {
            layoutContainer(parent);
        }
    });
    parent.setLayout(this);
}
项目:swingx    文件:BasicHeaderUI.java   
protected void installListeners(final JXHeader header) {
    propListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            onPropertyChange(header, evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
        }
    };
    boundsListener = new HierarchyBoundsAdapter() {
        @Override
        public void ancestorResized(HierarchyEvent e) {
            if (header == e.getComponent()) {
                View v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
                // view might get lost on LAF change ...
                if (v == null) {
                    descriptionPane.putClientProperty(BasicHTML.propertyKey, 
                            MultiLineSupport.createView(descriptionPane));
                    v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
                }
                if (v != null) {
                    Container tla = header.getTopLevelAncestor();
                    if (tla == null) {
                        tla = header.getParent();
                        while (tla.getParent() != null) {
                            tla = tla.getParent();
                        }
                    }
                    int h = Math.max(descriptionPane.getHeight(), tla.getHeight());
                    int w = Math.min(tla.getWidth(), header.getParent().getWidth());
                    // 35 = description pane insets, TODO: obtain dynamically
                    w -= 35 + header.getInsets().left + header.getInsets().right + descriptionPane.getInsets().left + descriptionPane.getInsets().right + imagePanel.getInsets().left + imagePanel.getInsets().right + imagePanel.getWidth() + descriptionPane.getBounds().x;
                    v.setSize(w, h);
                    descriptionPane.setSize(w, (int) Math.ceil(v.getPreferredSpan(View.Y_AXIS)));
                }
            }
        }};
    header.addPropertyChangeListener(propListener);
    header.addHierarchyBoundsListener(boundsListener);
}
项目:aibench-project    文件:BasicHeaderUI.java   
protected void installListeners(final JXHeader header) {
    propListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            onPropertyChange(header, evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
        }
    };
    boundsListener = new HierarchyBoundsAdapter() {
        @Override
        public void ancestorResized(HierarchyEvent e) {
            if (header == e.getComponent()) {
                View v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
                // view might get lost on LAF change ...
                if (v == null) {
                    descriptionPane.putClientProperty(BasicHTML.propertyKey, 
                            descriptionPane.getMultiLineSupport().createView(descriptionPane));
                    v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
                }
                if (v != null) {
                    Container tla = header.getTopLevelAncestor();
                    if (tla == null) {
                        tla = header.getParent();
                        while (tla.getParent() != null) {
                            tla = tla.getParent();
                        }
                    }
                    int h = Math.max(descriptionPane.getHeight(), tla.getHeight());
                    int w = Math.min(tla.getWidth(), header.getParent().getWidth());
                    // 35 = description pane insets, TODO: obtain dynamically
                    w -= 35 + header.getInsets().left + header.getInsets().right + descriptionPane.getInsets().left + descriptionPane.getInsets().right + imagePanel.getInsets().left + imagePanel.getInsets().right + imagePanel.getWidth() + descriptionPane.getBounds().x;
                    v.setSize(w, h);
                    descriptionPane.setSize(w, (int) Math.ceil(v.getPreferredSpan(View.Y_AXIS)));
                }
            }
        }};
    header.addPropertyChangeListener(propListener);
    header.addHierarchyBoundsListener(boundsListener);
}