JOptionPane.showMessageDialog truncates JTextArea message

后端 未结 4 1274
猫巷女王i
猫巷女王i 2021-01-15 04:20

My Java GUI application needs to quickly show some text to the end-user, so the JOptionPane utility methods seem like a good fit. Moreover, the text must be se

4条回答
  •  天涯浪人
    2021-01-15 04:48

    Try this:

    JTextArea textArea = new JTextArea();
    textArea.setText(getText());
    textArea.setSize(limit, Short.MAX_VALUE); // limit = width in pixels, e.g. 500
    textArea.setWrapStyleWord(true);
    textArea.setLineWrap(true);
    

提交回复
热议问题