Reputation: 2595
I have a JTextArea
with
text.setLineWrap(true);
text.setWrapStyleWord(true);
Now I have the problem, that if I start the GUI
containing some of this JTextArea
the text is correctly wrapped into 3-4 lines. Now I resize the GUI
to the rigth and the text is correctly expanded and just wrapped down to 1-2 lines. Now I start resizing the GUI
back to the left, but the JTextArea's
don't wrap back to the old state. They just stay wrapped to the 1-2 lines.
Upvotes: 0
Views: 168
Reputation: 42020
What kind of layout you are using? You need to use one that fits on the size of the window.
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);
}
Upvotes: 1