Hey everyone, I created a GUI project, where I'm using a JTree. When it's created everything is ok, but in my run() method when I call it i get a nullPointerExce ption. Here is the code.
of course I add stuff to the tree, but i'm not showing it here cause it's part of the project and personal data.
and in run() method
and the declaration of my variables
Code:
treePanel = new javax.swing.JPanel();
DefaultMutableTreeNode top =
new DefaultMutableTreeNode("blah");
mytree = new javax.swing.JTree(top);
javax.swing.GroupLayout treePanelLayout = new javax.swing.GroupLayout(treePanel);
treePanel.setLayout(treePanelLayout);
treePanelLayout.setHorizontalGroup(
treePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, treePanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
);
treePanelLayout.setVerticalGroup(
treePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, treePanelLayout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
and in run() method
Code:
mPanel= new JPanel(); mPanel.setLayout(new BoxLayout(mPanel,BoxLayout.X_AXIS)); mPanel.add(treePanel);
Code:
// Variables declaration - do not modify
private javax.swing.JComboBox jComboBox1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTree mytree;
private javax.swing.JPanel treePanel;
// End of variables declaration
Comment