What are the most common exceptions that occur when you are writing a program using AWT?

John Zukowski

Once your program has been tested, you shouldn't get any exceptions.... :-)

While in development mode, you may get a NullPointerException if you try to load an image before its ImageObserver is realized, among other possibilities. You may get ClassCastExceptions if you've made bad assumptions about data being passed and you didn't get with instanceof, or a SecurityException if you're trying to do something in an applet that it shouldn't.

[FAQ Manager Note] A few others you can also get:

  • IllegalArgumentException -- often occurs if passing a bad parameter value to a layout manager
  • ArrayIndexOutOfBoundsException -- when adding or removing components
  • NullPointerException -- very often, if you attempt to use an ImageIcon in Swing and the image doesn't exist
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact