llegalFormatConversionException error on java gui program
<pre><code>import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.net.*;
public class NameListListenerTest extends JFrame implements ActionListener{

    static ArrayList&lt;String&gt; nameList_2;
    static JFrame bframe;
    static JPanel p;
    //JButton userB;



    public NameListListenerTest() {
        try {
            JButton userB;
            //ArrayList&lt;String&gt; ls = new ArrayList&lt;String&gt;();

            String str = "hiwhatsupmate#!#jake sally joe#!#asdfasdf#!#kurt#!#";

            int start = str.indexOf("#!#");
            System.out.printf("%d\n", start);
            int end = str.indexOf("#!#", start+1);
            System.out.printf("%d\n",end);
            String userNames = str.substring(start+3, end-3);
            System.out.printf("%d\n",userNames);

            int x = userNames.length();
            while(true) {
                if(x &gt; 1) {
                    if(userNames.indexOf(" ") == 0)
                        nameList_2.add(userNames.substring(1,userNames.indexOf(" ",1)));
                    else
                        nameList_2.add(userNames.substring(0,userNames.indexOf(" ")));
                }
                else
                    break;
            }   
                p = new JPanel(new GridLayout(nameList_2.size(),1));
                for(int i=0; i&lt;nameList_2.size(); i++){
                    userB = new JButton(nameList_2.get(i));
                    userB.addActionListener(this);
                    p.add(userB);
                }
            }  catch (Exception e) {
                        e.printStackTrace();
                }
        }
    public static void main(String args[]) {
        //nameList_2.add("kurt");       
        bframe=new NameListListenerTest();  
        bframe.add(p);      

        bframe.setLocation(32,32);          
                bframe.setSize(50,500);
        bframe.setVisible(true);                
        bframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  

    }

    public void actionPerformed(ActionEvent e) {
        JButton jb = (JButton) e.getSource();
        System.out.printf("Connectin to user\n");

    }
}
</code></pre>

<p>My output is</p>

<pre><code>13
30 
java.util.IllegalFormatConversionException: d != java.lang.String
    at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
    at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)
    at java.util.Formatter$FormatSpecifier.print(Unknown Source)
    at java.util.Formatter.format(Unknown Source)
    at java.io.PrintStream.format(Unknown Source)
    at java.io.PrintStream.printf(Unknown Source)
    at NameListListenerTest.&lt;init&gt;(NameListListenerTest.java:28)
    at NameListListenerTest.main(NameListListenerTest.java:53)
Exception in thread "main" java.lang.NullPointerException
    at java.awt.Container.addImpl(Unknown Source)
    at java.awt.Container.add(Unknown Source)
    at javax.swing.JFrame.addImpl(Unknown Source)
    at java.awt.Container.add(Unknown Source)
    at NameListListenerTest.main(NameListListenerTest.java:54)
Process java exited with code 1
</code></pre>

<p>So my first to print statements worked, but i tried commenting out things and it seemed to be the exact same. I had this program working before without the entire substring and while loop part, but I manually put in a ArrayList then and just added four names right in the constructor </p>

<p>EDIT:</p>

<p>Now I'm getting </p>

<pre><code>java.lang.NullPointerException
    at NameListListenerTest.&lt;init&gt;(NameListListenerTest.java:36)
    at NameListListenerTest.main(NameListListenerTest.java:53)
Exception in thread "main" java.lang.NullPointerException
    at java.awt.Container.addImpl(Unknown Source)
    at java.awt.Container.add(Unknown Source)
    at javax.swing.JFrame.addImpl(Unknown Source)
    at java.awt.Container.add(Unknown Source)
    at NameListListenerTest.main(NameListListenerTest.java:54)
</code></pre>

<p>after the fixing of <code>%s</code></p>
