Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Null pointer exception from a TextArea or a JTextField, some help pls

843806May 16 2007 — edited May 16 2007
hei guys!

Sunny in your side of the world the same as in mine? :)

I'm trying to do a pop-up window (Frame) that will allow me to check some things from a checkPanel and insert a string in a JTextField. Then I have a TextArea object that is supposed to display me a string containing what I checked from my checkPanel together with the String inserted in the TextField when I click on a doneButton.

But the coded gives me a Null pointer exception and I have everything initialized...dunno what it can be...

I would really appreciat some help to move on with this part of my project!

Thank you for your time!!!
//constructor
 public SetNewFilter () {
...
        	
        JTextArea textArea = new JTextArea(5, 20);
	pane.add(checkPanel, c);
       JTextField textField=new JTextField(20);
       	pane.add(textField, c);
        pane.add(textArea,c);
//my done button
        Action doneAction = new DoneAction("Done");
        JButton doneButton= new JButton(doneAction);
        pane.add(doneButton,c);
}

class DoneAction extends AbstractAction {
    //public JTextField txtField;
    
    public DoneAction(String text) {
        super(text);
           }
    	
        public void actionPerformed(ActionEvent e) {
    	
    	String text = textField.getDocument();
    	      textArea.append("Your filter name is:"+text+"\n");
    	      textArea.append("Your filter will monitor after the following protocols:"+protocols);
    		textField.selectAll();
//protocols is a StringBuffer containig a String of what I checked in the the //checkpanel
//either the textArea either the textField don't reach this method :(...dunno why
    	}

Thanks again!

Cristina                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 13 2007
Added on May 16 2007
2 comments
475 views