I'm experiencing compilation error when I was trying to test my
tree model. In my FileListTreeModel class, which is implementing the
TreeModel interface, I defined the getRoot() as shown below so I can
see its behavior. My tree is being constructed in my JtreeDemo class.
Can anybody show me how I can correct this? Thanks.
/* JtreeDemo class */
iIpAddress = getIpAddress();
FileListTreeModel files = new FileListTreeModel(iIpAddress);
System.out.println("Jtree - root: " + files.getRoot());
DefaultTreeModel model = new DefaultTreeModel(files.getRoot());
JTree tree = new JTree(model);
JPanel panel = new JPanel(new GridLayout(0,1));
panel.add(new JScrollPane(tree));
/* FileListTreeModel class implementing TreeModel */
public Object getRoot() {
System.out.println("getRoot() called!"
Object root = null;
return root;
}
/* Compilation error */
C:\javaprog\cis178\cis178Assignment\Assign5JTree>javac socket\server\*java
socket\server\JtreeDemo.java:48: cannot resolve symbol
symbol : constructor DefaultTreeModel (java.lang.Object)
location: class javax.swing.tree.DefaultTreeModel
DefaultTreeModel model = new DefaultTreeModel(files.getRoot());
^
1 error
tree model. In my FileListTreeModel class, which is implementing the
TreeModel interface, I defined the getRoot() as shown below so I can
see its behavior. My tree is being constructed in my JtreeDemo class.
Can anybody show me how I can correct this? Thanks.
/* JtreeDemo class */
iIpAddress = getIpAddress();
FileListTreeModel files = new FileListTreeModel(iIpAddress);
System.out.println("Jtree - root: " + files.getRoot());
DefaultTreeModel model = new DefaultTreeModel(files.getRoot());
JTree tree = new JTree(model);
JPanel panel = new JPanel(new GridLayout(0,1));
panel.add(new JScrollPane(tree));
/* FileListTreeModel class implementing TreeModel */
public Object getRoot() {
System.out.println("getRoot() called!"
Object root = null;
return root;
}
/* Compilation error */
C:\javaprog\cis178\cis178Assignment\Assign5JTree>javac socket\server\*java
socket\server\JtreeDemo.java:48: cannot resolve symbol
symbol : constructor DefaultTreeModel (java.lang.Object)
location: class javax.swing.tree.DefaultTreeModel
DefaultTreeModel model = new DefaultTreeModel(files.getRoot());
^
1 error