Welcome to Dream.In.Code
Become a Java Expert!

Join 149,504 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,347 people online right now. Registration is fast and FREE... Join Now!




TreeEvents

 
Reply to this topicStart new topic

TreeEvents

mrithula
18 Sep, 2007 - 09:49 PM
Post #1

New D.I.C Head
*

Joined: 16 Sep, 2007
Posts: 11


My Contributions
Hi,
i hav another doubt in Java Trees....
i am getting an error while running the code below...

TreeEvents:java:18:cannot find symbol
symbol:class EEL
location:class TreeEvents
EEL eel=EEL.getInstance();

TreeEvents:java:18:cannot find symbol
symbol:variable EEL
location:class TreeEvents
EEL eel=EEL.getInstance();
2 errors



CODE

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
public class TreeEvents extends JFrame implements TreeSelectionListener{
JButton addB,deleteB;
JTree tree;


DefaultMutableTreeNode leadSelection;

public TreeEvents(){
super("Tree Events Demo");
setSize(300,200);
setDefaultCloseOperation(EXIT_ON_CLOSE);

EEL eel=EEL.getInstance();
eel.addGui();

tree=new JTree();
tree.setExpandsSelectedPaths(true);
tree.setEditable(true);
getContentPane().add(new JScrollPane(tree),BorderLayout.CENTER);
tree.addTreeSelectionListener(eel);
tree.addTreeSelectionListener(this);
tree.addTreeExpansionListener(eel);
tree.addTreeWillExpandListener(eel);
tree.addPropertyChangeListener(eel);
tree.getModel().addTreeModelListener(eel);
addB=new JButton("Add a node");
deleteB=new JButton("Delete a node");
JPanel buttonP=new JPanel();
buttonP.add(addB);
buttonP.add(deleteB);
getContentPane().add(buttonP,BorderLayout.SOUTH);

addB.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String nodeName=JOptionPane.showInputDialog("New node name");

if(leadSelection!=null){
leadSelection.add(new DefaultMutableTreeNode(nodeName));
((DefaultTreeModel)tree.getModel()).reload(leadSelection);
}
else{
JOptionPane.showMessageDialog(TreeEvents.this,"no parent..");
}
}
});

deleteB.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
if(leadSelection!=null){
DefaultMutableTreeNode parent=(DefaultMutableTreeNode)leadSelection.getParent();

if(parent==null){
JOptionPane.showMessageDialog(TreeEvents.this,"Can't delete root..");
}
else{
parent.remove(leadSelection);
leadSelection=null;
((DefaultTreeModel)tree.getModel()).reload(parent);
}
}
else{
JOptionPane.showMessageDialog(TreeEvents.this,"no selection..");
}
}
});

eel.showDialog();
}

public void valueChanged(TreeSelectionEvent e){
TreePath leadPath=e.getNewLeadSelectionPath();
if(leadPath!=null){
leadSelection=(DefaultMutableTreeNode)leadPath.getLastPathComponent();
}
}

public static void main(String a[])
{
TreeEvents te=new TreeEvents();
te.setVisible(true);
}
}

User is offlineProfile CardPM
+Quote Post

goldenthunder
RE: TreeEvents
19 Sep, 2007 - 12:29 AM
Post #2

New D.I.C Head
*

Joined: 18 Sep, 2007
Posts: 13


My Contributions
And what is EEL?

CODE
EEL eel=EEL.getInstance();

Its nowhere defined...

Eclipse cannot find it as a common Java Class.
If you are using some additional classes, it can be that you forgot to include them in classpath
User is offlineProfile CardPM
+Quote Post

mrithula
RE: TreeEvents
19 Sep, 2007 - 10:37 PM
Post #3

New D.I.C Head
*

Joined: 16 Sep, 2007
Posts: 11


My Contributions
QUOTE(goldenthunder @ 19 Sep, 2007 - 01:29 AM) *

And what is EEL?

CODE
EEL eel=EEL.getInstance();

Its nowhere defined...

Eclipse cannot find it as a common Java Class.
If you are using some additional classes, it can be that you forgot to include them in classpath


EEL is EveryEventListener.....
No am still not clear with this concept...
can u please tell me ....how to proceed further...

This post has been edited by mrithula: 19 Sep, 2007 - 10:40 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 06:48PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month