When i try to run the following code the following error pops up and I do not know why, it worked literally 10 minutes ago
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventPostProcessor(newKeyEventPostProcessor() {
public boolean postProcessKeyEvent(KeyEvent e) {
if (e.getID() == KeyEvent.KEY_PRESSED) {
if(e.isControlDown() && e.getKeyCode() == KeyEvent.VK_P){
printSinglePage();
e.consume();
}
if(e.isControlDown() && e.isAltDown() && e.getKeyCode() == KeyEvent.VK_P){
printAll();
e.consume();
}
}
return true;
}
});
public void printSinglePage(){
if(tab.getSelectedComponent() instanceof DuctReport)
PrintUtilities.printComponent(tab.getSelectedComponent(), DuctReport.PRINT_SIZE);
else if(tab.getSelectedComponent() instanceof Vandy)
PrintUtilities.printComponent(tab.getSelectedComponent(), Vandy.PRINT_SIZE);
else
PrintUtilities.printComponent(tab.getSelectedComponent(), .8);
}
public void printAll(){
for(int i = 0; i < tab.getTabCount(); i ++){
if(tab.getComponent(i) instanceof DuctReport)
PrintUtilities.printComponent(tab.getComponent(i), DuctReport.PRINT_SIZE);
else if(tab.getComponent(i) instanceof Vandy)
PrintUtilities.printComponent(tab.getComponent(i), Vandy.PRINT_SIZE);
else
PrintUtilities.printComponent(tab.getComponent(i), .8);
}
}
here is the error:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: PrintUtilities
at Main.printSinglePage(Main.java:282)
at Main.menPrintAllActionPerformed(Main.java:221)
at Main.access$600(Main.java:24)
at Main$8.actionPerformed(Main.java:148)
Typically, a
NoClassDefFoundErroris the result of classloader or classpath issues. Check that a jar hasn’t gotten renamed or moved, that your run script is correct, stuff like that. The code’s probably fine, it’s the environment.Please consider posting more details of your framework, IDE, and how the apps started if you’re still unable to fix this.