To break a message in two or more lines in JOptionPane

前端 未结 4 1325
礼貌的吻别
礼貌的吻别 2021-01-02 09:48
try {
        Class.forName(\"com.microsoft.sqlserver.jdbc.SQLServerDriver\");
        String connectionUrl = \"jdbc:sqlserver://\"+hostName.getText()+\";\" +
               


        
4条回答
  •  春和景丽
    2021-01-02 10:39

    You have to use \n to break the string in different lines. Or you can:

    Another way to accomplish this task is to subclass the JOptionPane class and override the getMaxCharactersPerLineCount so that it returns the number of characters that you want to represent as the maximum for one line of text.

    → http://ninopriore.com/2009/07/12/the-java-joptionpane-class/ (dead link, see archived copy).

提交回复
热议问题