你正在使用什么样的布局?您需要使用适合窗口大小的窗口。
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);
}
@Vegas我使用GridBagLayout。 –
@Paul Vargas'新的JTextArea(int,int);' – mKorbel