This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Exception in thread "AWT-EventQueue-1" " Watch "Exception in thread "AWT-EventQueue-1" " New topic
Author

Exception in thread "AWT-EventQueue-1"

Mike Croteau
Greenhorn

Joined: Apr 09, 2007
Posts: 8
Not sure whats going on here... my code is compiling fine, however, when run, I keep getting this AWT Exception.

at finalProject.address.AddressMain.takeAction(AddressMain.java:40)
at finalProject.address.Gui.addToAddressBook(Gui.java:70)
at finalProject.address.Gui.actionPerformed(Gui.java:47)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


Here is the code its breaking on... (heads up, I know some of this is redundant. Part of this assignment is to utilize class files that were given to me.)

My Gui's add button gets pressed:

private void addToAddressBook() {
new Thread();
System.out.println("add");
int action = ACTION_ADD;
AddressRecord addrss = new AddressRecord(firstName.getText(),
lastName.getText(),address.getText(),city.getText(),
state.getText(), zip.getText(),phoneNumber.getText(),
emailAddress.getText());
try {
AddressMain.takeAction(ACTION_ADD, addrss);
} catch (DuplicateException e1) {
e1.printStackTrace();
}
}

which gets passed to AddressMain.takeAction...

public static void takeAction(int action, AddressRecord a) throws DuplicateException {

System.out.println("action = " + action);

switch(action) {
case ACTION_ADD:
System.out.println("in ACTION_ADD case:");
System.out.println("action = " + action);
System.out.println("address = " + a);
addressBook.takeAction(action, a);
break;
case ACTION_REMOVE:
addressBook.takeAction(action, a);
gui.updateDisplay(addressBook.toString());
break;
case ACTION_FIND:
addressBook.takeAction(action, a);
gui.updateDisplay(addressBook.foundAddressesToString());
break;
case ACTION_DISPLAY:
gui.updateDisplay(addressBook.toString() );
break;
} //switch
} //takeAction


which then calls takeAction in my AddressBook... yes I know.

public void takeAction(int action, AddressRecord a) {
System.out.println("in AddressBook");
//System.out.println("address = " + a);
System.out.println("action = " + action);
switch(action){
case ACTION_ADD:
addToList(a);
break;
case ACTION_FIND:
findAddress(a);
break;
case ACTION_DISPLAY:
displayAddresses();
break;
case ACTION_REMOVE:
removeAddress(a);
break;
}

When running it, I keep getting the Exception when I press the add button. Im not even getting to the System.out within the takeAction in AddressBook. I am lost here and out of clues. Thanks in advance.

Mike
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

The exception appears to take place in the AddressMain class, at least from the stack trace you've given us:

Exactly what exception occurs and which line in AddressMain.takeAction() is line 40?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in thread "AWT-EventQueue-1"
 
Similar Threads
Open File Function
[newbie] Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Clicking works, but pushing "enter" return errors...how to fix? (on a button named "Enter")
Help me in getting the value of a cell after editing in Jtable
NullPointerException help....