-
netbeans gui problem
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:
Code:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
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.
Here is a part of the main class:
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...
In this part I get the exception:
Code:
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();
}
and the main code where all parts of the gui are initialized
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;
...
...
}
I tried every position to initialize my objects from outside of the gui. Does someone know what I do wrong?
(The code without the gui is working properly so that's not the problem)
-
Re: netbeans gui problem
NullPointerException:
Thrown when an application attempts to use null in a case where an object is required. These include:
* Calling the instance method of a null object.
* Accessing or modifying the field of a null object.
* Taking the length of null as if it were an array.
* Accessing or modifying the slots of null as if it were an array.
* Throwing null as if it were a Throwable value.
Applications should throw instances of this class to indicate other illegal uses of the null object.