Strange NullPointerException
[email protected] Mon, 23 May 2005 14:25:20 +0200
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Organization | kingmedia GmbH |
| Message-ID | <[email protected]> |
Hello,
I have taken one of the Swixml examples to write my own small Swing App. The
GUI renders fine, but when implementing my first action I ran into a
NullPointer exception... Here's my code:
public class ConfigBuilderUI extends WindowAdapter implements
ActionListener{
private SwingEngine ui;
private JButton b_button;
private JPanel p_config;
public static void main(String[] args) throws Exception{
new ConfigBuilderUI();
}
public AbstractAction submit = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
//TODO: Some action takes place
}
};
public ConfigBuilderUI() throws Exception{
//Create ui
ui = new SwingEngine(this);
ui.render("xml/configbuilder.xml");
//Init GUI components
p_config.setToolTipText("JUPPIE");
//Set visible
ui.getRootComponent().setVisible(true);
}
/**
* Invoked when an action occurs.
*/
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if ("AC_FILE_SELECT".equals( command )) {
System.out.println("Button clicked!");
}
}
}
...when trying to "p_config.setToolTipText("JUPPIE");" the app throws the
following exception:
java.lang.NullPointerException
at com.configbuilder.ui.ConfigBuilderUI.<init>(ConfigBuilderUI.java:50)
at com.configbuilder.ui.ConfigBuilderUI.main(ConfigBuilderUI.java:32)
Exception in thread "main"
I cannot understand this, because the documention says, that the gui
components are initialized automatically.
I will appreciate any hints! Thanks in advance,
Sebastian