Can't find root of NullPointerException

Need a second pair of eyes to check this over, It's only partially complete, I havn't implemented the main functionality yet, but it should be reading the label from a button and sending it to a textfield.

import java.awt.*;

public class FileName extends java.applet.Applet

{

final int MAX_FILENAME = 12;

final int MAX_EXTENSION = 3;

Panel ip;

TextField input;

TextField output;

StringBuffer currentinput;

char currentchar;

public void init()

{

setBackground(Color.white);

input = new TextField(20);

input.setEditable(false);

output = new TextField(25);

output.setEditable(false);

Label filename = new Label("Filename:");

add(filename);

add(input);

Label result = new Label("Result:");

add(result);

add(output);

ip = new Panel();

ip.setLayout(new GridLayout(5,8,6,6));

for (char input=97; input < 123; input++)

{

Character c = new Character(input);

ip.add(new Button(c.toString()));

}

for (char input=48; input <= 57; input++)

{

Character c = new Character(input);

ip.add(new Button(c.toString()));

}

ip.add(new Button("."));

add(ip);

}

public boolean action(Event evt, Object arg)

{

String label = (String) arg;

if (evt.target instanceof Button)

{

currentchar = label.charAt(0);

currentinput.append(currentchar);

input.setText(currentinput.toString());

return true;

}

return true;

}

}

Apparently the "NPE" is in this line: "currentinput.append(currentchar);"

[1686 byte] By [adamwa] at [2007-10-3 3:28:36]
# 1
> Apparently the "NPE" is in this line:> "currentinput.append(currentchar);"Then currentinput is null.Next time, when you post code, please ues [code] and [/code] tags around it to preserve formatting and make it easier to read.
jverda at 2007-7-14 21:22:12 > top of Java-index,Java Essentials,New To Java...
# 2
StringBuffer currentinput; is the declaration, but the new StringBuffer() part is missing in your code.
PhHeina at 2007-7-14 21:22:12 > top of Java-index,Java Essentials,New To Java...
# 3

> StringBuffer currentinput;

> currentinput.append(currentchar);

> Apparently the "NPE" is in this line: "currentinput.append(currentchar);"

Those were the only two lines I could find that refer to 'currentinput'.

Obviously none of these lines actually assign a StringBuffer to that variable.

Hence the NullPointerException.

kind regards,

Jos

JosAHa at 2007-7-14 21:22:12 > top of Java-index,Java Essentials,New To Java...
# 4
Apologies for not using the [code] tag, I will do in future. Thanks for pointing out my failure to initialise the stringbuffer, it works fine now.
adamwa at 2007-7-14 21:22:12 > top of Java-index,Java Essentials,New To Java...