hi. can any one help. i am doing a java application. and using a button listener class. and says cannot find the text box object. can you help. will do the sample code. how to get this to work. marvin. ps: here's the code if(e.ActionCommand().equals("btnName"}} {JOptionPane.showMessageDialog("My name is: " + txtName {+ " "); System.exit(0); } how to fix this. what is the correct code. and then get this error. marvin.

without seeing the rest of the code, that's a bit difficult. is your textbox declared in a scope unreachable for the actionPerformed, maybe?
personally, I prefer the

public void actionPerformed(ActionEvent e) {
        if(e.getSource() == button1)
    }

approach, bit easier to read.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.