Problems with event handling in JmenuItem

Hello:

I'm trying to handle an event for a menuItem and tool bar item: with this code:

newBallotAction = new AbstractAction("newBallot")

{

public void actionPerformed(ActionEvent e)

{

try{

System.out.println("MainWindow newBallotAction");

Ballot ballot = new Ballot();

System.out.println("MainWindow newBallotAction 2nd");

DDNewBallotWindow ddNewBallotWindow = new DDNewBallotWindow(ballot);

if (ballot != null) // <ballotName>, <ballotOptionsNumber> , <ballotOption1>, <ballotOption2>, .., <ballotOption(optionsNumber)>

{

brothers.msgToBrothers("<Ballot>" + "<origin>" + myName + "</origin>"+ ballot.toRep() +"</Ballot>" , myName);

}

else

{

System.out.println("MainWindow ballot null");

}

}catch(Exception f){

System.out.println("MainWindow newBallotAction exception" + e);

}

}

};

JMenuItem ballotMIDdMenu = new JMenuItem("New Ballot");

ballotMIDdMenu = fileMenu.add(newBallotAction);

ddMenu.add(ballotMIDdMenu);

It produces the next exception:

MainWindow newBallotAction exceptionjava.awt.event.ActionEvent[ACTION_PERFORMED,cmd=newBallot] on javax.swing.JMenu$2[,1,49,137x21,alignmentX=null,alignmentY=null,border=javax.swing.plaf.metal.MetalBorders$MenuItemBorder@55a338,flags=264,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=2,bottom=2,right=2],paintBorder=true,paintFocus=false,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=newBallot]

It's really complex ... I'm desperado ;)

Thanks in advance, Nacho.

[1848 byte] By [viento2] at [2007-9-26 2:15:29]
# 1
What is the actual exception? You are printing out the ActionEvent (e) instead of the exception (f).
dukeman at 2007-6-29 9:12:42 > top of Java-index,Archived Forums,Swing...
# 2
Hi,The exception is propably occuring in the Ballot() constructor (which you didn't post).And, as dukeman already mentionned, you are printing out the ActionEvent object and not the Exception itself.
leukbr at 2007-6-29 9:12:42 > top of Java-index,Archived Forums,Swing...
# 3
Upss an stupid mistake, I know. Thank you, it was just an null pointer exception. Thanks again. Nacho.
viento2 at 2007-6-29 9:12:42 > top of Java-index,Archived Forums,Swing...