Hi,
I wrote a program without GUI and now I'm trying to implement it in a GUI. I developed a GUI with the netbeans gui editor.
While implementing, i've got no errors but at runtime I get the following exception:
I think it's because my objects aren't properly initialized. I don't know where to initialize them in the gui code of netbeans.Code:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Here is a part of the main class:
In this part I get the exception:Code:public class frame_wysiwyg extends javax.swing.JFrame { /** Creates new form frame_wysiwyg */ public frame_wysiwyg() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code "> private void initComponents() { frameCreateEvent = new javax.swing.JFrame(); wizardCreateEvent = new javax.swing.JPanel(); jLabel12 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); etc...
and the main code where all parts of the gui are initializedCode:private void addConversationButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: vier = (int)((Integer.parseInt(valueIdOne.getText()))); vijf = (int)((Integer.parseInt(valueIdTwo.getText()))); gui_event.nieuwGesprek(vier,vijf); <--HERE I GET THE EXCEPTION int temp_aantal_gesprekken = (int)((Integer.parseInt(nrofconversations.getText()))); temp_aantal_gesprekken++ ; nrofconversations.setText(Integer.toString(temp_aantal_gesprekken)); frameAddConversation.dispose(); }
I tried every position to initialize my objects from outside of the gui. Does someone know what I do wrong?Code:public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new frame_wysiwyg().setVisible(true); } }); // Variables declaration - do not modify private javax.swing.JMenuBar MenuBar; private javax.swing.JButton addConversationButton; private javax.swing.JMenuItem addConversationMenuItem; ... ... }
(The code without the gui is working properly so that's not the problem)




Reply With Quote