/** * 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); } } } }}); }
/** * 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); } } } }}); }
/** * 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); } } } }}); }
/** * 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); } } } }}); }
/** * 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); } } } }}); }