When the code runs it should show the ChoicesPanel & depending on what the user chooses a SubChoicesPanel is displayed at the side of the ChoicesPanel. I havwe had the ChoicesPanel working but when I attempted to create the SubChoicesPanel I am getting a NullPointerException. Starting application C:\Documents and Settings\Dave Johnson\Desktop\BarTill\BarTill.class java.lang.NullPointerException at ChoicesPanel.actionPerformed(ChoicesPanel.java:63) at java.awt.Button.processActionEvent(Button.java:382) at java.awt.Button.processEvent(Button.java:350) at java.awt.Component.dispatchEventImpl(Component.java:3615) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) Interactive Session Ended Interactive Session Ended
after just a quick review you are passing a reference 'b' new BarTill() to choicesPanel. that instance is never used or initialized. try passing 'this' instead (a reference to the initilized applet) you may also need to used the swing utilities invokeLater method to add the panel as well as code to remove the current choices panel and then add the new one. you might also consider starting with a default choices panel
posted 15 years ago
I have changed my init() method as suggested i.e:
It still doesn't seem to be right though. Admittedly I am trying this on awful editor (crimson editor) I might wait till I get home later on a better seyup before trying out too much. If anyone has any other ideas I can try please post? Thanks, Dave.