Hallo liebe Forengemeinde,
ich schreibe an einer GUI mittels Jigloo.
Sie zeigt über eine GUI Variablen an, die in einem Property-File stehen. Das klappt auch soweit.
Gibt nun der Anwender einen neuen Wert in die GUI ein, so horcht ein PropertyChangeListener darauf und soll den neuen Wert in das File schreiben. Leider wirft er mir eine Null Pointer exception (siehe unten) und speichert nichts in das File. Habt ihr eine Idee warum?
Vielen Dank vorab für Eure Vorschläge
Viele Grüße
Antje
P.S. die NullpointerException ist nicht das Problem. Vermute ihren Hintergrund. (s. Beitrag unten)
Die Fehlermeldung lautet:
ich schreibe an einer GUI mittels Jigloo.
Sie zeigt über eine GUI Variablen an, die in einem Property-File stehen. Das klappt auch soweit.
Gibt nun der Anwender einen neuen Wert in die GUI ein, so horcht ein PropertyChangeListener darauf und soll den neuen Wert in das File schreiben. Leider wirft er mir eine Null Pointer exception (siehe unten) und speichert nichts in das File. Habt ihr eine Idee warum?
Vielen Dank vorab für Eure Vorschläge
Viele Grüße
Antje
P.S. die NullpointerException ist nicht das Problem. Vermute ihren Hintergrund. (s. Beitrag unten)
Java:
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CEPFrame inst = new CEPFrame();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
}
});
}
public CEPFrame() {
super();
initGUI();
}
private void initGUI() {
...
final Properties propGUI = new Properties();
try {
propGUI.load(this.getClass().getResourceAsStream("/statement.properties"));
} catch (IOException e1) {
e1.printStackTrace();
}
...
String brands = propGUI.getProperty("brands");
...
jTextField1.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() == jTextField1){
jTextField1.setText(evt.getNewValue().toString());
propGUI.setProperty("brands", evt.getNewValue().toString());
try{
FileOutputStream fos = new FileOutputStream("/statement.properties");
propGUI.store(fos, "");
}catch(Exception e){e.printStackTrace();}
}
}
}
...
}
Die Fehlermeldung lautet:
Java:
Exception in thread AWT-EventQueue-0 java.lang.NullPointerException
at SocialMediaCEP.GUI.CEPFrame$8.propertyChange(CEPFrame.java384)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at java.awt.Component.firePropertyChange(Unknown Source)
at javax.swing.JComponent.removeNotify(Unknown Source)
at javax.swing.text.JTextComponent.removeNotify(Unknown Source)
at java.awt.Container.removeNotify(Unknown Source)
at javax.swing.JComponent.removeNotify(Unknown Source)
at java.awt.Container.removeNotify(Unknown Source)
at javax.swing.JComponent.removeNotify(Unknown Source)
at java.awt.Container.removeNotify(Unknown Source)
at javax.swing.JComponent.removeNotify(Unknown Source)
at java.awt.Container.removeNotify(Unknown Source)
at javax.swing.JComponent.removeNotify(Unknown Source)
at java.awt.Container.removeNotify(Unknown Source)
at javax.swing.JComponent.removeNotify(Unknown Source)
at java.awt.Container.removeNotify(Unknown Source)
at javax.swing.JComponent.removeNotify(Unknown Source)
at javax.swing.JRootPane.removeNotify(Unknown Source)
at java.awt.Container.removeNotify(Unknown Source)
at java.awt.Window.removeNotify(Unknown Source)
at java.awt.Frame.removeNotify(Unknown Source)
at java.awt.Window$1DisposeAction.run(Unknown Source)
at java.awt.Window.doDispose(Unknown Source)
at java.awt.Window.dispose(Unknown Source)
at javax.swing.JFrame.processWindowEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Zuletzt bearbeitet: