home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-26 | 31.2 KB | 875 lines |
- /*
- A basic extension of the java.applet.Applet class
- */
-
- /*
- Code written by Christopher Bernard
- Internet Tools Technical Support Team
- Symantec
- */
-
- import java.awt.*;
- import java.applet.*;
- import symantec.itools.awt.TreeView;
- import symantec.itools.awt.TreeNode;
- import symantec.itools.awt.LabelButton;
- import symantec.itools.multimedia.SlideShow;
- import symantec.itools.awt.ImageButton;
- import symantec.itools.awt.shape.Rect;
- import symantec.itools.multimedia.ImageViewer;
- public class TreeViewApplet extends Applet
- {
- public void init()
- {
- // Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
- symantec.itools.lang.Context.setApplet(this);
-
- // This code is automatically generated by Visual Cafe when you add
- // components to the visual environment. It instantiates and initializes
- // the components. To modify the code, only use code syntax that matches
- // what Visual Cafe can generate, or Visual Cafe may be unable to back
- // parse your Java file into its visual environment.
- //{{INIT_CONTROLS
- setLayout(new BorderLayout(0,0));
- setSize(709,371);
- setFont(new Font("Dialog", Font.BOLD, 12));
- setBackground(new Color(16711935));
- panel1 = new java.awt.Panel();
- panel1.setLayout(new GridLayout(1,3,0,0));
- panel1.setBounds(0,0,709,371);
- panel1.setBackground(new Color(4210752));
- add("Center", panel1);
- panel2 = new java.awt.Panel();
- GridBagLayout gridBagLayout;
- gridBagLayout = new GridBagLayout();
- panel2.setLayout(gridBagLayout);
- panel2.setBounds(0,0,709,371);
- panel1.add(panel2);
- panel9 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel9.setLayout(gridBagLayout);
- panel9.setBounds(5,5,226,361);
- panel9.setBackground(new Color(16711935));
- GridBagConstraints gbc;
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(5,5,5,5);
- ((GridBagLayout)panel2.getLayout()).setConstraints(panel9, gbc);
- panel2.add(panel9);
- treeView1 = new symantec.itools.awt.TreeView();
- {
- java.lang.String[] tempString = new java.lang.String[1];
- tempString[0] = new java.lang.String("root");
- treeView1.setTreeStructure(tempString);
- }
- treeView1.setBounds(0,0,226,361);
- treeView1.setFont(new Font("Dialog", Font.PLAIN, 12));
- treeView1.setForeground(new Color(0));
- treeView1.setBackground(new Color(16777215));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel9.getLayout()).setConstraints(treeView1, gbc);
- panel9.add(treeView1);
- panel10 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel10.setLayout(gridBagLayout);
- panel10.setBounds(236,0,354,371);
- panel1.add(panel10);
- panel3 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel3.setLayout(gridBagLayout);
- panel3.setBounds(0,5,231,361);
- panel3.setBackground(new Color(16777215));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(5,0,5,5);
- ((GridBagLayout)panel10.getLayout()).setConstraints(panel3, gbc);
- panel10.add(panel3);
- label3 = new java.awt.Label(" Insert a node with the following name");
- label3.setBounds(0,9,230,23);
- label3.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel3.getLayout()).setConstraints(label3, gbc);
- panel3.add(label3);
- textFieldInsert = new java.awt.TextField();
- textFieldInsert.setBounds(5,48,221,23);
- textFieldInsert.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,5,0,5);
- ((GridBagLayout)panel3.getLayout()).setConstraints(textFieldInsert, gbc);
- panel3.add(textFieldInsert);
- panel6 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel6.setLayout(gridBagLayout);
- panel6.setBounds(0,79,231,85);
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 2;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel3.getLayout()).setConstraints(panel6, gbc);
- panel3.add(panel6);
- label2 = new java.awt.Label(" as the:");
- label2.setBounds(20,2,57,23);
- label2.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel6.getLayout()).setConstraints(label2, gbc);
- panel6.add(label2);
- Group1 = new CheckboxGroup();
- radioButtonChild = new java.awt.Checkbox("child", Group1, true);
- radioButtonChild.setBounds(98,2,56,23);
- radioButtonChild.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 1;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel6.getLayout()).setConstraints(radioButtonChild, gbc);
- panel6.add(radioButtonChild);
- radioButtonLast = new java.awt.Checkbox("last sibling", Group1, false);
- radioButtonLast.setBounds(98,58,90,23);
- radioButtonLast.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 1;
- gbc.gridy = 2;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel6.getLayout()).setConstraints(radioButtonLast, gbc);
- panel6.add(radioButtonLast);
- radioButtonNext = new java.awt.Checkbox("next sibling", Group1, false);
- radioButtonNext.setBounds(98,30,92,23);
- radioButtonNext.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 1;
- gbc.gridy = 1;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel6.getLayout()).setConstraints(radioButtonNext, gbc);
- panel6.add(radioButtonNext);
- label1 = new java.awt.Label(" of the currently selected node");
- label1.setBounds(28,172,186,23);
- label1.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 5;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,12,0,0);
- ((GridBagLayout)panel3.getLayout()).setConstraints(label1, gbc);
- panel3.add(label1);
- label4 = new java.awt.Label(" The new node will use");
- label4.setBounds(38,211,155,23);
- label4.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 6;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel3.getLayout()).setConstraints(label4, gbc);
- panel3.add(label4);
- panel5 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel5.setLayout(gridBagLayout);
- panel5.setBounds(0,242,231,39);
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 7;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel3.getLayout()).setConstraints(panel5, gbc);
- panel3.add(panel5);
- buttonPrevious = new java.awt.Button();
- buttonPrevious.setLabel("Prev.");
- buttonPrevious.setBounds(6,8,67,23);
- buttonPrevious.setFont(new Font("Dialog", Font.BOLD, 12));
- buttonPrevious.setForeground(new Color(255));
- buttonPrevious.setBackground(new Color(12632256));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,5,0,0);
- ((GridBagLayout)panel5.getLayout()).setConstraints(buttonPrevious, gbc);
- panel5.add(buttonPrevious);
- buttonPrevious.setEnabled(false);
- slideShow1 = new symantec.itools.multimedia.SlideShow();
- try {
- slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("arrowclosed.gif"), "");
- slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("circleclosed.gif"), "");
- slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("folderclosed.gif"), "");
- slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("defaultclosed.gif"), "");
- } catch (Exception e) { }
- slideShow1.setBounds(97,12,20,15);
- gbc = new GridBagConstraints();
- gbc.gridx = 1;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.anchor = GridBagConstraints.EAST;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel5.getLayout()).setConstraints(slideShow1, gbc);
- panel5.add(slideShow1);
- slideShow2 = new symantec.itools.multimedia.SlideShow();
- try {
- slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("arrowopened.gif"), "");
- slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("circleopened.gif"), "");
- slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("folderopened.gif"), "");
- slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("defaultopened.gif"), "");
- } catch (Exception e) { }
- slideShow2.setBounds(117,12,20,15);
- gbc = new GridBagConstraints();
- gbc.gridx = 2;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel5.getLayout()).setConstraints(slideShow2, gbc);
- panel5.add(slideShow2);
- buttonNext = new java.awt.Button();
- buttonNext.setLabel("Next");
- buttonNext.setBounds(161,8,64,23);
- buttonNext.setFont(new Font("Dialog", Font.BOLD, 12));
- buttonNext.setForeground(new Color(255));
- buttonNext.setBackground(new Color(12632256));
- gbc = new GridBagConstraints();
- gbc.gridx = 3;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,0,0,5);
- ((GridBagLayout)panel5.getLayout()).setConstraints(buttonNext, gbc);
- panel5.add(buttonNext);
- label5 = new java.awt.Label(" as its images");
- label5.setBounds(63,289,104,23);
- label5.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 8;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel3.getLayout()).setConstraints(label5, gbc);
- panel3.add(label5);
- buttonInsert = new java.awt.Button();
- buttonInsert.setLabel("Insert");
- buttonInsert.setBounds(5,328,221,23);
- buttonInsert.setFont(new Font("Dialog", Font.BOLD, 12));
- buttonInsert.setForeground(new Color(255));
- buttonInsert.setBackground(new Color(12632256));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 9;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,5,0,5);
- ((GridBagLayout)panel3.getLayout()).setConstraints(buttonInsert, gbc);
- panel3.add(buttonInsert);
- panel4 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel4.setLayout(gridBagLayout);
- panel4.setBounds(472,0,236,371);
- panel1.add(panel4);
- panel11 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel11.setLayout(gridBagLayout);
- panel11.setBounds(0,5,231,101);
- panel11.setBackground(new Color(16777215));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(5,0,0,5);
- ((GridBagLayout)panel4.getLayout()).setConstraints(panel11, gbc);
- panel4.add(panel11);
- panel7 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel7.setLayout(gridBagLayout);
- panel7.setBounds(5,0,221,101);
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(0,5,0,5);
- ((GridBagLayout)panel11.getLayout()).setConstraints(panel7, gbc);
- panel11.add(panel7);
- panel8 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel8.setLayout(gridBagLayout);
- panel8.setBounds(0,0,69,101);
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.gridheight = 2;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel7.getLayout()).setConstraints(panel8, gbc);
- panel7.add(panel8);
- label8 = new java.awt.Label("tree color");
- label8.setBounds(0,6,69,23);
- label8.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel8.getLayout()).setConstraints(label8, gbc);
- panel8.add(label8);
- label9 = new java.awt.Label("status");
- label9.setBounds(0,39,69,23);
- label9.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel8.getLayout()).setConstraints(label9, gbc);
- panel8.add(label9);
- label7 = new java.awt.Label("# nodes");
- label7.setBounds(0,72,69,23);
- label7.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 2;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel8.getLayout()).setConstraints(label7, gbc);
- panel8.add(label7);
- panel14 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel14.setLayout(gridBagLayout);
- panel14.setBounds(69,0,151,101);
- gbc = new GridBagConstraints();
- gbc.gridx = 1;
- gbc.gridy = 0;
- gbc.weightx = 10.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel7.getLayout()).setConstraints(panel14, gbc);
- panel7.add(panel14);
- choiceTreeColor = new java.awt.Choice();
- choiceTreeColor.addItem("black");
- choiceTreeColor.addItem("blue");
- choiceTreeColor.addItem("red");
- choiceTreeColor.addItem("green");
- choiceTreeColor.addItem("yellow");
- choiceTreeColor.addItem("orange");
- choiceTreeColor.addItem("purple");
- try {
- choiceTreeColor.select(0);
- }
- catch (IllegalArgumentException e) { }
- choiceTreeColor.setBounds(0,5,151,21);
- choiceTreeColor.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel14.getLayout()).setConstraints(choiceTreeColor, gbc);
- panel14.add(choiceTreeColor);
- textFieldStatus = new java.awt.TextField();
- textFieldStatus.setEditable(false);
- textFieldStatus.setText("waiting for input");
- textFieldStatus.setBounds(0,37,151,23);
- textFieldStatus.setFont(new Font("Dialog", Font.PLAIN, 12));
- textFieldStatus.setForeground(new Color(8421504));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel14.getLayout()).setConstraints(textFieldStatus, gbc);
- panel14.add(textFieldStatus);
- textFieldCount = new java.awt.TextField();
- textFieldCount.setEditable(false);
- textFieldCount.setText("1");
- textFieldCount.setBounds(0,71,151,23);
- textFieldCount.setFont(new Font("Dialog", Font.PLAIN, 12));
- textFieldCount.setForeground(new Color(8421504));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 2;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel14.getLayout()).setConstraints(textFieldCount, gbc);
- panel14.add(textFieldCount);
- panel15 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel15.setLayout(gridBagLayout);
- panel15.setBounds(0,111,231,65);
- panel15.setBackground(new Color(16777215));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(5,0,5,5);
- ((GridBagLayout)panel4.getLayout()).setConstraints(panel15, gbc);
- panel4.add(panel15);
- buttonNew = new java.awt.Button();
- buttonNew.setLabel("Create New Tree");
- buttonNew.setBounds(5,21,221,23);
- buttonNew.setFont(new Font("Dialog", Font.BOLD, 12));
- buttonNew.setForeground(new Color(-16744320));
- buttonNew.setBackground(new Color(12632256));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(5,5,5,5);
- ((GridBagLayout)panel15.getLayout()).setConstraints(buttonNew, gbc);
- panel15.add(buttonNew);
- panel13 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel13.setLayout(gridBagLayout);
- panel13.setBounds(0,181,231,124);
- panel13.setBackground(new Color(16777215));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 2;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(0,0,0,5);
- ((GridBagLayout)panel4.getLayout()).setConstraints(panel13, gbc);
- panel4.add(panel13);
- label6 = new java.awt.Label(" Delete the first node encountered");
- label6.setBounds(13,4,205,23);
- label6.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel13.getLayout()).setConstraints(label6, gbc);
- panel13.add(label6);
- label10 = new java.awt.Label(" with the following name");
- label10.setBounds(39,35,152,23);
- label10.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,0,0);
- ((GridBagLayout)panel13.getLayout()).setConstraints(label10, gbc);
- panel13.add(label10);
- textFieldDelete = new java.awt.TextField();
- textFieldDelete.setBounds(5,66,221,23);
- textFieldDelete.setFont(new Font("Dialog", Font.PLAIN, 12));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 2;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,5,0,5);
- ((GridBagLayout)panel13.getLayout()).setConstraints(textFieldDelete, gbc);
- panel13.add(textFieldDelete);
- buttonDelete = new java.awt.Button();
- buttonDelete.setLabel("Delete");
- buttonDelete.setBounds(5,97,221,23);
- buttonDelete.setFont(new Font("Dialog", Font.BOLD, 12));
- buttonDelete.setForeground(new Color(16711680));
- buttonDelete.setBackground(new Color(12632256));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 3;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,5,0,5);
- ((GridBagLayout)panel13.getLayout()).setConstraints(buttonDelete, gbc);
- panel13.add(buttonDelete);
- panel12 = new java.awt.Panel();
- gridBagLayout = new GridBagLayout();
- panel12.setLayout(gridBagLayout);
- panel12.setBounds(0,310,231,55);
- panel12.setBackground(new Color(16777215));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 3;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(5,0,5,5);
- ((GridBagLayout)panel4.getLayout()).setConstraints(panel12, gbc);
- panel4.add(panel12);
- buttonDeleteSelected = new java.awt.Button();
- buttonDeleteSelected.setLabel("Delete selected node");
- buttonDeleteSelected.setBounds(5,16,221,23);
- buttonDeleteSelected.setFont(new Font("Dialog", Font.BOLD, 12));
- buttonDeleteSelected.setForeground(new Color(16711680));
- buttonDeleteSelected.setBackground(new Color(12632256));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = new Insets(0,5,0,5);
- ((GridBagLayout)panel12.getLayout()).setConstraints(buttonDeleteSelected, gbc);
- panel12.add(buttonDeleteSelected);
- //}}
-
- //INITIALIZE THE COUNTER FIELD: used to display the current number of
- //nodes contained by the tree
- textFieldCount.setText("" + treeView1.getCount());
-
- //LOAD ALL OF THE IMAGES INTO THE APPLET'S MEMORY VIA A MEDIA TRACKER: If
- //you don't do it this way, the images of each node will not show up the
- //first time they are drawn.
- Image tempImage1 = this.getImage(this.getDocumentBase(), "arrowclosed.gif" );
- Image tempImage2 = this.getImage(this.getDocumentBase(), "arrowopened.gif" );
- Image tempImage3 = this.getImage(this.getDocumentBase(), "folderclosed.gif");
- Image tempImage4 = this.getImage(this.getDocumentBase(), "folderopened.gif");
- Image tempImage5 = this.getImage(this.getDocumentBase(), "circleclosed.gif");
- Image tempImage6 = this.getImage(this.getDocumentBase(), "circleopened.gif");
-
- myImageLoader = new MediaTracker(treeView1);
- try{
- myImageLoader.addImage(tempImage1,1);
- myImageLoader.addImage(tempImage2,1);
- myImageLoader.addImage(tempImage3,1);
- myImageLoader.addImage(tempImage4,1);
- myImageLoader.addImage(tempImage5,1);
- myImageLoader.addImage(tempImage6,1);
- myImageLoader.waitForAll();
- }catch (Exception e) {System.out.println(e);}
-
- //{{REGISTER_LISTENERS
- SymAction lSymAction = new SymAction();
- buttonDeleteSelected.addActionListener(lSymAction);
- buttonDelete.addActionListener(lSymAction);
- buttonInsert.addActionListener(lSymAction);
- buttonNext.addActionListener(lSymAction);
- buttonPrevious.addActionListener(lSymAction);
- SymItem lSymItem = new SymItem();
- choiceTreeColor.addItemListener(lSymItem);
- buttonNew.addActionListener(lSymAction);
- //}}
- }
-
- //{{DECLARE_CONTROLS
- java.awt.Panel panel1;
- java.awt.Panel panel2;
- java.awt.Panel panel9;
- symantec.itools.awt.TreeView treeView1;
- java.awt.Panel panel10;
- java.awt.Panel panel3;
- java.awt.Label label3;
- java.awt.TextField textFieldInsert;
- java.awt.Panel panel6;
- java.awt.Label label2;
- java.awt.Checkbox radioButtonChild;
- CheckboxGroup Group1;
- java.awt.Checkbox radioButtonLast;
- java.awt.Checkbox radioButtonNext;
- java.awt.Label label1;
- java.awt.Label label4;
- java.awt.Panel panel5;
- java.awt.Button buttonPrevious;
- symantec.itools.multimedia.SlideShow slideShow1;
- symantec.itools.multimedia.SlideShow slideShow2;
- java.awt.Button buttonNext;
- java.awt.Label label5;
- java.awt.Button buttonInsert;
- java.awt.Panel panel4;
- java.awt.Panel panel11;
- java.awt.Panel panel7;
- java.awt.Panel panel8;
- java.awt.Label label8;
- java.awt.Label label9;
- java.awt.Label label7;
- java.awt.Panel panel14;
- java.awt.Choice choiceTreeColor;
- java.awt.TextField textFieldStatus;
- java.awt.TextField textFieldCount;
- java.awt.Panel panel15;
- java.awt.Button buttonNew;
- java.awt.Panel panel13;
- java.awt.Label label6;
- java.awt.Label label10;
- java.awt.TextField textFieldDelete;
- java.awt.Button buttonDelete;
- java.awt.Panel panel12;
- java.awt.Button buttonDeleteSelected;
- //}}
-
- //THE NEW NODE TO BE INSERTED
- TreeNode newNode;
- //THE CURRENTLY SELECTED NODE
- TreeNode currentNode;
- //THE OPEN AND CLOSED VIEW OF EACH IMAGE
- Image newNodeOpened, newNodeClosed;
- String openedImageName, closedImageName;
- //MEDIA TRACKER FOR LOADING IN IMAGES ON INITIALIZATION
- MediaTracker myImageLoader;
-
- //BUTTONS: event handler code
- class SymAction implements java.awt.event.ActionListener
- {
- public void actionPerformed(java.awt.event.ActionEvent event)
- {
- Object object = event.getSource();
- if (object == buttonDeleteSelected)
- buttonDeleteSelected_Action(event);
- else if (object == buttonDelete)
- buttonDelete_Action(event);
- else if (object == buttonInsert)
- buttonInsert_Action(event);
- else if (object == buttonNext)
- buttonNext_Action(event);
- else if (object == buttonPrevious)
- buttonPrevious_Action(event);
- else if (object == buttonNew)
- buttonNew_Action(event);
- }
- }
-
- //BUTTON DELETE SELECTED NODE IS CLICKED: Delete the currently
- //selected node.
- void buttonDeleteSelected_Action(java.awt.event.ActionEvent event)
- {
- treeView1.removeSelected();
- treeView1.repaint();
- textFieldCount.setText("" + treeView1.getCount());
-
- //update the status field
- textFieldStatus.setText("node deleted");
- if (textFieldCount.getText().equals("0")){
- textFieldStatus.setText("press: Create New Tree");
- }
- }
-
- //BUTTON DELETE (SPECIFIC NAMED NODE) IS CLICKED: Delete the node whose
- //name matches that listed in the textFieldDelete text field.
- void buttonDelete_Action(java.awt.event.ActionEvent event)
- {
- treeView1.remove(textFieldDelete.getText());
- treeView1.repaint();
- textFieldCount.setText("" + treeView1.getCount());
-
- //update the status field
- textFieldStatus.setText("node deleted");
- if (textFieldCount.getText().equals("0")){
- textFieldStatus.setText("press: Create New Tree");
- }
- }
-
- //BUTTON INSERT IS CLICKED: Insert a new node onto the tree
- void buttonInsert_Action(java.awt.event.ActionEvent event)
- {
- //get the image
- updateImage();
-
- newNodeClosed = this.getImage(this.getDocumentBase(), closedImageName);
- newNodeOpened = this.getImage(this.getDocumentBase(), openedImageName);
-
- //get the position
- int selectedRadioButton = 0;
- if (radioButtonChild.getState() == true){ selectedRadioButton = 0; }
- if (radioButtonNext.getState() == true){ selectedRadioButton = 1; }
- if (radioButtonLast.getState() == true){ selectedRadioButton = 2; }
-
- //get the label
- String newNodeText = textFieldInsert.getText();
-
- //do the insert
- newNode = new TreeNode(newNodeText, newNodeClosed, newNodeOpened, treeView1);
- currentNode = treeView1.getSelectedNode();
- treeView1.insert(newNode, currentNode, selectedRadioButton);
- treeView1.redraw();
- textFieldCount.setText("" + treeView1.getCount());
-
- //update the status field
- textFieldStatus.setText("node inserted");
- }
-
- //HELPER FUNCTION OF INSERT BUTTONS CODE: sets the image pointer
- //used for the new node (openedImageName, closedImageName) to the
- //appropriat graphic.
- //I also used this function to keep track of the previous and next
- //button's enabled property. It makes for a better UI to have them
- //disabled when they can't do anything.
- void updateImage()
- {
- int selectedImage = slideShow1.getCurrentImageIndex();
-
- if (selectedImage == 0){
- openedImageName = "arrowopened.gif";
- closedImageName = "arrowclosed.gif";
-
- //disable the previous button for use
- buttonPrevious.setEnabled(false);
-
- }else if (selectedImage == 1){
- openedImageName = "circleopened.gif";
- closedImageName = "circleclosed.gif";
-
- //enable the previous button for use
- buttonPrevious.setEnabled(true);
-
- }else if (selectedImage == 2){
- openedImageName = "folderopened.gif";
- closedImageName = "folderclosed.gif";
-
- //enable the next button for use
- buttonNext.setEnabled(true);
-
- }else{
- openedImageName = null;
- closedImageName = null;
-
- //disable the next button for use
- buttonNext.setEnabled(false);
-
- }
- }
-
- //BUTTON NEXT IS CLICKED: go to the next option for
- //node graphics in the slideShow component
- void buttonNext_Action(java.awt.event.ActionEvent event)
- {
- slideShow2.nextImage();
- slideShow1.nextImage();
- updateImage();
-
- //update the status field
- textFieldStatus.setText("choosing image");
- }
-
- //BUTTON PREVIOUS IS CLICKED: go to the previous option for
- //node graphics in the slideShow component
- void buttonPrevious_Action(java.awt.event.ActionEvent event)
- {
- slideShow2.previousImage();
- slideShow1.previousImage();
- updateImage();
-
- //update the status field
- textFieldStatus.setText("choosing image");
- }
-
- //BUTTON NEW IS CLICKED: Create a new tree
- void buttonNew_Action(java.awt.event.ActionEvent event)
- {
- java.lang.String[] tempString = new java.lang.String[1];
- tempString[0] = new java.lang.String("root");
- treeView1.setTreeStructure(tempString);
- textFieldCount.setText("" + treeView1.getCount());
-
- //update the status field
- textFieldStatus.setText("new tree created");
- }
-
- //COLOR SELECTED FROM CHOICE BOX: event handler
- class SymItem implements java.awt.event.ItemListener
- {
- public void itemStateChanged(java.awt.event.ItemEvent event)
- {
- Object object = event.getSource();
- if (object == choiceTreeColor)
- choiceTreeColor_ItemStateChanged(event);
- }
- }
-
- //COLOR SELECTED FROM CHOICE BOX: select the color to display the tree in
- void choiceTreeColor_ItemStateChanged(java.awt.event.ItemEvent event)
- {
- String selectedColor = choiceTreeColor.getSelectedItem();
-
- if (selectedColor == "black" ) {treeView1.setForeground(Color.black) ;}
- else if (selectedColor == "blue" ) {treeView1.setForeground(Color.blue) ;}
- else if (selectedColor == "red" ) {treeView1.setForeground(Color.red) ;}
- else if (selectedColor == "green" ) {treeView1.setForeground(Color.green) ;}
- else if (selectedColor == "yellow") {treeView1.setForeground(Color.yellow) ;}
- else if (selectedColor == "orange") {treeView1.setForeground(Color.orange );}
- else if (selectedColor == "purple") {treeView1.setForeground(Color.magenta);}
- treeView1.redraw();
- }
-
- }
-