To break a message in two or more lines in JOptionPane

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


        
4条回答
  •  北海茫月
    2021-01-02 10:49

    enter image description here

    import javax.swing.*;
    
    class FixedWidthLabel {
    
        public static void main(String[] args) {
            Runnable r = () -> {
                String html = "

    Label Width

    " + "

    Many Swing components support HTML 3.2 & " + "(simple) CSS. By setting a body width we can cause " + "the component to find the natural height needed to " + "display the component.

    " + "

    The body width in this text is set to %1s pixels."; // change to alter the width int w = 175; JOptionPane.showMessageDialog(null, String.format(html, w, w)); }; SwingUtilities.invokeLater(r); } }

提交回复
热议问题