• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception in thread "AWT-EventQueue-1"

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic