[英]JTextArea wrapping only once at the creation of the text area
我有一个JTextArea
text.setLineWrap(true);
text.setWrapStyleWord(true);
现在,我遇到的问题是,如果启动包含某些JTextArea
的GUI
,则文本将正确地包装为3-4行。 现在,我将GUI
调整为正确的大小,并且文本已正确扩展,并且仅缩减为1-2行。 现在,我开始将GUI
调整为左侧,但是JTextArea's
状态不会退回到原来的状态。 他们只是停留在1-2行。
您正在使用哪种布局? 您需要使用一个适合窗口大小的窗口。
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
Locale[] locales = Locale.getAvailableLocales();
for (int i = 0; i < locales.length; i++) {
sb.append(locales[i].getDisplayCountry()).append(' ');
}
JTextArea textArea = new JTextArea(sb.toString());
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(textArea);
JFrame frame = new JFrame("All installed locales");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(scrollPane);
frame.pack();
frame.setVisible(true);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.