• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable PrinterException not recognized by compiler

 
Rc Armstrong
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I import javax.swing.* and make a JTable which works. Then I add a try/catch block for table.print() catching PrinterException. The compiler error is "PrinterException cannot be resolved to a type." Are there other requirements?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!
You seem to have forgotten to import the required package for PrinterException
 
Fred Kleinschmidt
Bartender
Posts: 451
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that as Maneeesh pointed out, PrinterException is not in the javax.swing.* packages. Also, it is usually a better ide to0 import only the packages you need, rather than using wild cards. So instead of "javax.swing.*" import "javax.swing.JTable" and any others that you use. The reason for this is that there are some often classes with the same name in more than one package; using the wild card you might inadvertently end up importing the wrong class. This is especially true when you create your own class that happens to have the same name as an existing Java class.
 
Rc Armstrong
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both Maneesh and Fred. The books I saw just did not seem to have that point. I am sure that will do it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!