내가 사용하는 솔루션은 다음과 같이 진행됩니다
1) 사용자 정의
2 LabelUI
)를 LabelUI는 사용자가 제공 한 타원 스윙 타원을 대체 할 수있는 layoutCL() 메소드를 오버라이드 (override)를 등록합니다.
public class LabelUI extends MetalLabelUI {
private static final int SWING_ELLIPSES_LEN = "...".length();
private static final ComponentUI LABEL_UI_INSTANCE = new LabelUI();
private String displayedText;
public static ComponentUI createUI(JComponent c) {
return LABEL_UI_INSTANCE;
}
public String getText() {
return displayedText;
}
protected String layoutCL(JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR) {
displayedText = super.layoutCL(label, fontMetrics, text, icon, viewR, iconR, textR);
String truncationString = (String)label.getClientProperty("LabelUI.truncationString");
if (truncationString != null && !displayedText.equals(text)) {
displayedText = displayedText.subSequence(0, displayedText.length() - SWING_ELLIPSES_LEN) + truncationString;
}
return displayedText;
}
}
3) 구성 요소에 클라이언트 속성을 설정하여 새 줄임표를 제공하십시오.
JLabel component = ... ;
component.putClientProperty("LabelUI.truncationString", ">");
참고 사항 [예제] (http://stackoverflow.com/a/3597688/230513). – trashgod