Professional Documents
Culture Documents
06 Hands-On Activity 1
06 Hands-On Activity 1
BSIT 301
Part 1
OUTPUT
CODE:
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
JFrame f;
Jtree() {
f = new JFrame();
html.add(head);
html.add(body);
head.add(meta);
head.add(title);
body.add(ul);
body.add(h1);
body.add(h2);
ul.add(li);
ul.add(lI);
h2.add(a);
f.add(jt);
f.setSize(300, 300);
f.setVisible(true);
new Jtree();
}
Part 2
root.add(n1);
root.add(n2);
n1.add(head1);
n1.add(head2);
n2.add(body1);
n2.add(body2);
n2.add(body3);
body1.add(ul1);
body1.add(ul2);
body3.add(h21);
System.out.println (body1+"-
"+Collections.list(body1.children()));System.out.println (body3+"-
"+Collections.list(body3.children()));
List bfe =
Collections.list(root.breadthFirstEnumeration());System.out.println ("List of
nodes based on breadth-first: "+bfe);
List po = Collections.list(root.postorderEnumeration());System.out.println
("List of nodes based on postorder: "+po);
this.setTitle("JFrame Example");
this.setSize(300,300);this.setVisible(true);