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.

