• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

problem with handles in JTree

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It happens that when I click on the handle icon of the ancestor node, an Exception occurs:
java.lang.NullPointerException
What is goin' on?
----------------------------------
Here is code snippet:

void jTree1_valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)jTree1.getLastSelectedPathComponent();
Object birac = node.getUserObject();
TreePath niz = (TreePath)jTree1.getLeadSelectionPath();

jTextArea1.setText("");
if (jTree1.isVisible(niz)) {
if (node.isLeaf()) {
My_Class bt = (My_Class)birac;
String tabela1 = bt.getImeTabele();
if (qds1.isOpen()) {
try {
qds1.close();
} catch (Exception ex){} } //if
...
...
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Srbija
You can use the following condition
If(<object> != null)
{
Your code;
}
Regards
Antony
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!