문제

I am using html to make text in a JLabel span multiple lines. However if I enter a long string with no spaces it doesn't go onto a new line and instead causes an underlying JScrollpane to display a horizontal scrollbar and pushs the components to the right of the JLabel out of the view area. So anyone know if it is possible to word wrap strings without spaces in a JLabel?

도움이 되었습니까?

해결책

You can use a JTextAreafor that purpose:

JTextArea ta = new JTextArea();
ta.setEditable(false);
ta.setLineWrap(true);
ta.setOpaque(false);
ta.setWrapStyleWord(false); // This makes wrapping on char boundaries, and I think is the default value
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top