title: Putting a table-border around a <span> in Java Swing
body: <p>I have a GUI related question. I am attempting to use create a GUI using a JOptionsPane as well as JPanel, JText and JLabel. Now that I have accomplished building my GUI and getting the  tag to work my next goal is to create a table around the formatted text of my GUI, I will post my code below to illustrate: </p>
  
  <pre><code>String css = "&lt;span style='font-size:10; color: white; background-color:black'&gt;";
  String batchCss = "&lt;span style='font-size: 20'&gt;";
  String cssBorder = "&lt;span style='border:1px dotted red'&gt;";
  String endSpanCss = "&lt;/span&gt;"; String table = "
  &lt;table border=4&gt;"; String endTable = "&lt;/table&gt;"; String text = "
  &lt;html&gt;" + table + css + batchCss + "1 of 2" +endSpanCss+ endSpanCss + endTable + "
      &lt;br&gt;Entry Detail:" + "
      &lt;br&gt;11111111111111111111111111+ "
      &lt;br&gt;
      &lt;br&gt;Please type 1-21 to apply a reason code and addenda record to the entry detail." + "
      &lt;br&gt;Please type 'h' and press any button to open the help screen." + "
      &lt;br&gt;
      &lt;br&gt;
      &lt;br&gt;Reason Codes" + "
      &lt;br&gt;R01 - Insufficient Funds" + "
      &lt;br&gt;R02 - Account Closed" + "
      &lt;br&gt;R03 - No Account" + "
      &lt;br&gt;R04 - Invalid Account Number" + "
      &lt;br&gt;R05 - Unauthorized Debit to Consumer Account" + "
      &lt;br&gt;R06 - Returned per ODFI Request" + "
      &lt;br&gt;R07 - Auth Revoked by Customer" + "
      &lt;br&gt;R08 - Payment Stopped" + "
      &lt;br&gt;R09 - Uncollected Funds" + "
      &lt;br&gt;R10 - Customer Advises Not Authorized" + "
      &lt;br&gt;R11 - Check Truncation Entry Return" + "
      &lt;br&gt;R12 - Branch Sold to Another DFI" + "
      &lt;br&gt;R13 - Invalid ACH Routing Number" + "
      &lt;br&gt;R14 - Represenative Payee Deceased or Unable to Continue" + "
      &lt;br&gt;R15 - Beneficiary or Account Holder Deceased" + "
      &lt;br&gt;R16 - Account Frozen" + "
      &lt;br&gt;R17 - File Record Edit Criteria" + "
      &lt;br&gt;R18 - Improper Effective Entry Date" + "
      &lt;br&gt;R19 - Account Field Error" + "
      &lt;br&gt;R20 - Non-Transaction Amount" + "
      &lt;br&gt;R21 - Invalid Company Information" + "
      &lt;br&gt;R22 - Invalid Individual ID Number";
  </code></pre>
  
  <p>Someone yesterday got me started with the CSS which works, but now I need to figure out how to put some type of table around the whole thing so I can organize this text-heavy dialog. I have tried to use a CSS tag like  <code>&lt;span style='border:1px dottec red'&gt;</code> as you can see from my variables, but this had no effect. </p>
  
  <p>When I add the standard HTML table tag outside the CSS it works however my CSS no longer works (as you can see if you test the program). Removing the table border will again allow the CSS to work.</p>
  
  <p>How can I get the <code>span style='border'</code> to work, or how can I get the table border to work with the CSS? </p>
  
  <p>EDITED: </p>
  
  <p>Here is additionally runnable code as requested. </p>
  
  <pre><code>package nacha;
  
  import java.awt.BorderLayout;
  
  import javax.swing.JLabel;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.JTextField;
  
  public class Testing4 
  
  {
  
      public static void main(String args[]){
  
          String css = "&lt;span style='font-size:10; color: white; background-color:black'; border:&gt;";
          String batchCss = "&lt;span style='font-size: 20'&gt;";
          String endSpanCss = "&lt;/span&gt;"; 
          String table = "&lt;table border=4&gt;";
          String endTable = "&lt;/table&gt;"; 
          String mainCss = "&lt;span style='font-size:12; color: red'&gt;";
          String header1Css = "&lt;span style = 'font-size:15; font-weight:bold;text-decoration:underline;border:1px dotted red'&gt;";
          String text1Css = "&lt;span style = 'font-size:12; font-style:italic'&gt;";
  
  
  
           String text = "&lt;html&gt;" +
                  css + batchCss + "1 of 2"+endSpanCss+endSpanCss+ endSpanCss +
                  "&lt;br&gt;&lt;br&gt;&lt;br&gt;"+header1Css+"Entry Detail:"+endSpanCss +
                  "&lt;br&gt;"+mainCss+"111111111111111111111"+endSpanCss+
                  "&lt;br&gt;&lt;br&gt;&lt;br&gt;"+text1Css+"Please type 1-21 to apply a reason code and addenda record to the entry detail." +
                  "&lt;br&gt;Please type 'h' and press the next entry button to open the help screen."+endSpanCss +
                  "&lt;br&gt;&lt;br&gt;&lt;br&gt;"+header1Css+"Reason Codes"+ endSpanCss +
                  "&lt;br&gt;"+table+"R01 - Insufficient Funds" +
                  "&lt;br&gt;R02 - Account Closed" +
                  "&lt;br&gt;R03 - No Account" +
                  "&lt;br&gt;R04 - Invalid Account Number" +
                  "&lt;br&gt;R05 - Unauthorized Debit to Consumer Account" +
                  "&lt;br&gt;R06 - Returned per ODFI Request" +
                  "&lt;br&gt;R07 - Auth Revoked by Customer" +
                  "&lt;br&gt;R08 - Payment Stopped" +
                  "&lt;br&gt;R09 - Uncollected Funds" +
                  "&lt;br&gt;R10 - Customer Advises Not Authorized" +
                  "&lt;br&gt;R11 - Check Truncation Entry Return" +
                  "&lt;br&gt;R12 - Branch Sold to Another DFI" +
                  "&lt;br&gt;R13 - Invalid ACH Routing Number" +
                  "&lt;br&gt;R14 - Represenative Payee Deceased or Unable to Continue" +
                  "&lt;br&gt;R15 - Beneficiary or Account Holder Deceased" +
                  "&lt;br&gt;R16 - Account Frozen" +
                  "&lt;br&gt;R17 - File Record Edit Criteria" +
                  "&lt;br&gt;R18 - Improper Effective Entry Date" +
                  "&lt;br&gt;R19 - Account Field Error" +
                  "&lt;br&gt;R20 - Non-Transaction Amount" +
                  "&lt;br&gt;R21 - Invalid Company Information" +
                  "&lt;br&gt;R22 - Invalid Individual ID Number"+endTable;
  
           //Below code creates the GUI for the return builder portion of the program. 
            Object[] options1 = {"Next Entry","Next Batch","Finished"};//Changes the default buttons. 
            BorderLayout border = new BorderLayout();
            JPanel panel = new JPanel();     
            panel.setLayout(border);
            panel.add(new JLabel(text),BorderLayout.NORTH);//Adds the label to the top of the panel.               
            JTextField textField = new JTextField(10); 
            panel.add(textField,BorderLayout.SOUTH);//Adds a user-input text area to the bottom of the panel.
  
            int result = JOptionPane.showOptionDialog(null, panel, "Return Builder", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options1, JOptionPane.YES_OPTION);
  
      }
  
  }
  </code></pre>
  
  <p>You will find the line giving me trouble is: </p>
  
  <pre><code>String header1Css = "&lt;span style = 'font-size:15; font-weight:bold;text-decoration:underline;border:1px dotted red'&gt;";
  </code></pre>
  
  <p>I have set that line to have a 1 px dotted red border. That format string is called here:</p>
  
  <pre><code>"&lt;br&gt;&lt;br&gt;&lt;br&gt;"+header1Css+"Entry Detail:"+endSpanCss +
  </code></pre>
  
  <p>And the result is the "Entry Detail:" line is formatted correctly for everything except the border. </p>