相关疑难解决方法(0)

在JOptionPane中断两行或多行中的消息

try {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        String connectionUrl = "jdbc:sqlserver://"+hostName.getText()+";" +
        "databaseName="+dbName.getText()+";user="+userName.getText()+";password="+password.getText()+";";
        Connection con = DriverManager.getConnection(connectionUrl);
        if(con!=null){JOptionPane.showMessageDialog(this, "Connection Established");}
        } catch (SQLException e) {
            JOptionPane.showMessageDialog(this, e);
            //System.out.println("SQL Exception: "+ e.toString());
        } catch (ClassNotFoundException cE) {
            //System.out.println("Class Not Found Exception: "+ cE.toString());
             JOptionPane.showMessageDialog(this, cE.toString());
        }
Run Code Online (Sandbox Code Playgroud)

出现错误时,它会显示一个长的JOptionPane消息框,该消息框长于计算机屏幕的宽度.如何将e.toString()分成两个或多个部分.

java swing newline joptionpane

8
推荐指数
1
解决办法
3万
查看次数

标签 统计

java ×1

joptionpane ×1

newline ×1

swing ×1