/**
* 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);
}
}
}
}});
}
JXLabel.java 文件源码
java
阅读 32
收藏 0
点赞 0
评论 0
项目:swingx
作者:
评论列表
文章目录