home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / WDESAMPL.BIN / TreeViewApplet.java < prev    next >
Text File  |  1998-02-26  |  32KB  |  875 lines

  1. /*
  2.     A basic extension of the java.applet.Applet class
  3. */
  4.  
  5. /*
  6.     Code written by Christopher Bernard
  7.     Internet Tools Technical Support Team
  8.     Symantec
  9. */
  10.  
  11. import java.awt.*;
  12. import java.applet.*;
  13. import symantec.itools.awt.TreeView;
  14. import symantec.itools.awt.TreeNode;
  15. import symantec.itools.awt.LabelButton;
  16. import symantec.itools.multimedia.SlideShow;
  17. import symantec.itools.awt.ImageButton;
  18. import symantec.itools.awt.shape.Rect;
  19. import symantec.itools.multimedia.ImageViewer;
  20. public class TreeViewApplet extends Applet
  21. {
  22.     public void init()
  23.     {
  24.         // Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
  25.         symantec.itools.lang.Context.setApplet(this);
  26.     
  27.         // This code is automatically generated by Visual Cafe when you add
  28.         // components to the visual environment. It instantiates and initializes
  29.         // the components. To modify the code, only use code syntax that matches
  30.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  31.         // parse your Java file into its visual environment.
  32.         //{{INIT_CONTROLS
  33.         setLayout(new BorderLayout(0,0));
  34.         setSize(709,371);
  35.         setFont(new Font("Dialog", Font.BOLD, 12));
  36.         setBackground(new Color(16711935));
  37.         panel1 = new java.awt.Panel();
  38.         panel1.setLayout(new GridLayout(1,3,0,0));
  39.         panel1.setBounds(0,0,709,371);
  40.         panel1.setBackground(new Color(4210752));
  41.         add("Center", panel1);
  42.         panel2 = new java.awt.Panel();
  43.         GridBagLayout gridBagLayout;
  44.         gridBagLayout = new GridBagLayout();
  45.         panel2.setLayout(gridBagLayout);
  46.         panel2.setBounds(0,0,709,371);
  47.         panel1.add(panel2);
  48.         panel9 = new java.awt.Panel();
  49.         gridBagLayout = new GridBagLayout();
  50.         panel9.setLayout(gridBagLayout);
  51.         panel9.setBounds(5,5,226,361);
  52.         panel9.setBackground(new Color(16711935));
  53.         GridBagConstraints gbc;
  54.         gbc = new GridBagConstraints();
  55.         gbc.gridx = 0;
  56.         gbc.gridy = 0;
  57.         gbc.weightx = 1.0;
  58.         gbc.weighty = 1.0;
  59.         gbc.fill = GridBagConstraints.BOTH;
  60.         gbc.insets = new Insets(5,5,5,5);
  61.         ((GridBagLayout)panel2.getLayout()).setConstraints(panel9, gbc);
  62.         panel2.add(panel9);
  63.         treeView1 = new symantec.itools.awt.TreeView();
  64.         {
  65.             java.lang.String[] tempString = new java.lang.String[1];
  66.             tempString[0] = new java.lang.String("root");
  67.             treeView1.setTreeStructure(tempString);
  68.         }
  69.         treeView1.setBounds(0,0,226,361);
  70.         treeView1.setFont(new Font("Dialog", Font.PLAIN, 12));
  71.         treeView1.setForeground(new Color(0));
  72.         treeView1.setBackground(new Color(16777215));
  73.         gbc = new GridBagConstraints();
  74.         gbc.gridx = 0;
  75.         gbc.gridy = 0;
  76.         gbc.weightx = 1.0;
  77.         gbc.weighty = 1.0;
  78.         gbc.fill = GridBagConstraints.BOTH;
  79.         gbc.insets = new Insets(0,0,0,0);
  80.         ((GridBagLayout)panel9.getLayout()).setConstraints(treeView1, gbc);
  81.         panel9.add(treeView1);
  82.         panel10 = new java.awt.Panel();
  83.         gridBagLayout = new GridBagLayout();
  84.         panel10.setLayout(gridBagLayout);
  85.         panel10.setBounds(236,0,354,371);
  86.         panel1.add(panel10);
  87.         panel3 = new java.awt.Panel();
  88.         gridBagLayout = new GridBagLayout();
  89.         panel3.setLayout(gridBagLayout);
  90.         panel3.setBounds(0,5,231,361);
  91.         panel3.setBackground(new Color(16777215));
  92.         gbc = new GridBagConstraints();
  93.         gbc.gridx = 0;
  94.         gbc.gridy = 0;
  95.         gbc.weightx = 1.0;
  96.         gbc.weighty = 1.0;
  97.         gbc.fill = GridBagConstraints.BOTH;
  98.         gbc.insets = new Insets(5,0,5,5);
  99.         ((GridBagLayout)panel10.getLayout()).setConstraints(panel3, gbc);
  100.         panel10.add(panel3);
  101.         label3 = new java.awt.Label("    Insert a node with the following name");
  102.         label3.setBounds(0,9,230,23);
  103.         label3.setFont(new Font("Dialog", Font.PLAIN, 12));
  104.         gbc = new GridBagConstraints();
  105.         gbc.gridx = 0;
  106.         gbc.gridy = 0;
  107.         gbc.weightx = 1.0;
  108.         gbc.weighty = 1.0;
  109.         gbc.fill = GridBagConstraints.NONE;
  110.         gbc.insets = new Insets(0,0,0,0);
  111.         ((GridBagLayout)panel3.getLayout()).setConstraints(label3, gbc);
  112.         panel3.add(label3);
  113.         textFieldInsert = new java.awt.TextField();
  114.         textFieldInsert.setBounds(5,48,221,23);
  115.         textFieldInsert.setFont(new Font("Dialog", Font.PLAIN, 12));
  116.         gbc = new GridBagConstraints();
  117.         gbc.gridx = 0;
  118.         gbc.gridy = 1;
  119.         gbc.weightx = 1.0;
  120.         gbc.weighty = 1.0;
  121.         gbc.fill = GridBagConstraints.HORIZONTAL;
  122.         gbc.insets = new Insets(0,5,0,5);
  123.         ((GridBagLayout)panel3.getLayout()).setConstraints(textFieldInsert, gbc);
  124.         panel3.add(textFieldInsert);
  125.         panel6 = new java.awt.Panel();
  126.         gridBagLayout = new GridBagLayout();
  127.         panel6.setLayout(gridBagLayout);
  128.         panel6.setBounds(0,79,231,85);
  129.         gbc = new GridBagConstraints();
  130.         gbc.gridx = 0;
  131.         gbc.gridy = 2;
  132.         gbc.weightx = 1.0;
  133.         gbc.weighty = 1.0;
  134.         gbc.fill = GridBagConstraints.BOTH;
  135.         gbc.insets = new Insets(0,0,0,0);
  136.         ((GridBagLayout)panel3.getLayout()).setConstraints(panel6, gbc);
  137.         panel3.add(panel6);
  138.         label2 = new java.awt.Label("  as the:");
  139.         label2.setBounds(20,2,57,23);
  140.         label2.setFont(new Font("Dialog", Font.PLAIN, 12));
  141.         gbc = new GridBagConstraints();
  142.         gbc.gridx = 0;
  143.         gbc.gridy = 0;
  144.         gbc.weightx = 1.0;
  145.         gbc.weighty = 1.0;
  146.         gbc.fill = GridBagConstraints.NONE;
  147.         gbc.insets = new Insets(0,0,0,0);
  148.         ((GridBagLayout)panel6.getLayout()).setConstraints(label2, gbc);
  149.         panel6.add(label2);
  150.         Group1 = new CheckboxGroup();
  151.         radioButtonChild = new java.awt.Checkbox("child", Group1, true);
  152.         radioButtonChild.setBounds(98,2,56,23);
  153.         radioButtonChild.setFont(new Font("Dialog", Font.PLAIN, 12));
  154.         gbc = new GridBagConstraints();
  155.         gbc.gridx = 1;
  156.         gbc.gridy = 0;
  157.         gbc.weightx = 1.0;
  158.         gbc.weighty = 1.0;
  159.         gbc.anchor = GridBagConstraints.WEST;
  160.         gbc.fill = GridBagConstraints.NONE;
  161.         gbc.insets = new Insets(0,0,0,0);
  162.         ((GridBagLayout)panel6.getLayout()).setConstraints(radioButtonChild, gbc);
  163.         panel6.add(radioButtonChild);
  164.         radioButtonLast = new java.awt.Checkbox("last sibling", Group1, false);
  165.         radioButtonLast.setBounds(98,58,90,23);
  166.         radioButtonLast.setFont(new Font("Dialog", Font.PLAIN, 12));
  167.         gbc = new GridBagConstraints();
  168.         gbc.gridx = 1;
  169.         gbc.gridy = 2;
  170.         gbc.weightx = 1.0;
  171.         gbc.weighty = 1.0;
  172.         gbc.anchor = GridBagConstraints.WEST;
  173.         gbc.fill = GridBagConstraints.NONE;
  174.         gbc.insets = new Insets(0,0,0,0);
  175.         ((GridBagLayout)panel6.getLayout()).setConstraints(radioButtonLast, gbc);
  176.         panel6.add(radioButtonLast);
  177.         radioButtonNext = new java.awt.Checkbox("next sibling", Group1, false);
  178.         radioButtonNext.setBounds(98,30,92,23);
  179.         radioButtonNext.setFont(new Font("Dialog", Font.PLAIN, 12));
  180.         gbc = new GridBagConstraints();
  181.         gbc.gridx = 1;
  182.         gbc.gridy = 1;
  183.         gbc.weightx = 1.0;
  184.         gbc.weighty = 1.0;
  185.         gbc.anchor = GridBagConstraints.WEST;
  186.         gbc.fill = GridBagConstraints.NONE;
  187.         gbc.insets = new Insets(0,0,0,0);
  188.         ((GridBagLayout)panel6.getLayout()).setConstraints(radioButtonNext, gbc);
  189.         panel6.add(radioButtonNext);
  190.         label1 = new java.awt.Label("    of the currently selected node");
  191.         label1.setBounds(28,172,186,23);
  192.         label1.setFont(new Font("Dialog", Font.PLAIN, 12));
  193.         gbc = new GridBagConstraints();
  194.         gbc.gridx = 0;
  195.         gbc.gridy = 5;
  196.         gbc.weightx = 1.0;
  197.         gbc.weighty = 1.0;
  198.         gbc.fill = GridBagConstraints.NONE;
  199.         gbc.insets = new Insets(0,12,0,0);
  200.         ((GridBagLayout)panel3.getLayout()).setConstraints(label1, gbc);
  201.         panel3.add(label1);
  202.         label4 = new java.awt.Label("      The new node will use");
  203.         label4.setBounds(38,211,155,23);
  204.         label4.setFont(new Font("Dialog", Font.PLAIN, 12));
  205.         gbc = new GridBagConstraints();
  206.         gbc.gridx = 0;
  207.         gbc.gridy = 6;
  208.         gbc.weightx = 1.0;
  209.         gbc.weighty = 1.0;
  210.         gbc.fill = GridBagConstraints.NONE;
  211.         gbc.insets = new Insets(0,0,0,0);
  212.         ((GridBagLayout)panel3.getLayout()).setConstraints(label4, gbc);
  213.         panel3.add(label4);
  214.         panel5 = new java.awt.Panel();
  215.         gridBagLayout = new GridBagLayout();
  216.         panel5.setLayout(gridBagLayout);
  217.         panel5.setBounds(0,242,231,39);
  218.         gbc = new GridBagConstraints();
  219.         gbc.gridx = 0;
  220.         gbc.gridy = 7;
  221.         gbc.weightx = 1.0;
  222.         gbc.weighty = 1.0;
  223.         gbc.fill = GridBagConstraints.BOTH;
  224.         gbc.insets = new Insets(0,0,0,0);
  225.         ((GridBagLayout)panel3.getLayout()).setConstraints(panel5, gbc);
  226.         panel3.add(panel5);
  227.         buttonPrevious = new java.awt.Button();
  228.         buttonPrevious.setLabel("Prev.");
  229.         buttonPrevious.setBounds(6,8,67,23);
  230.         buttonPrevious.setFont(new Font("Dialog", Font.BOLD, 12));
  231.         buttonPrevious.setForeground(new Color(255));
  232.         buttonPrevious.setBackground(new Color(12632256));
  233.         gbc = new GridBagConstraints();
  234.         gbc.gridx = 0;
  235.         gbc.gridy = 0;
  236.         gbc.weightx = 1.0;
  237.         gbc.weighty = 1.0;
  238.         gbc.fill = GridBagConstraints.HORIZONTAL;
  239.         gbc.insets = new Insets(0,5,0,0);
  240.         ((GridBagLayout)panel5.getLayout()).setConstraints(buttonPrevious, gbc);
  241.         panel5.add(buttonPrevious);
  242.         buttonPrevious.setEnabled(false);
  243.         slideShow1 = new symantec.itools.multimedia.SlideShow();
  244.         try {
  245.             slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("arrowclosed.gif"), "");
  246.             slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("circleclosed.gif"), "");
  247.             slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("folderclosed.gif"), "");
  248.             slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("defaultclosed.gif"), "");
  249.         } catch (Exception e) { }
  250.         slideShow1.setBounds(97,12,20,15);
  251.         gbc = new GridBagConstraints();
  252.         gbc.gridx = 1;
  253.         gbc.gridy = 0;
  254.         gbc.weightx = 1.0;
  255.         gbc.weighty = 1.0;
  256.         gbc.anchor = GridBagConstraints.EAST;
  257.         gbc.fill = GridBagConstraints.NONE;
  258.         gbc.insets = new Insets(0,0,0,0);
  259.         ((GridBagLayout)panel5.getLayout()).setConstraints(slideShow1, gbc);
  260.         panel5.add(slideShow1);
  261.         slideShow2 = new symantec.itools.multimedia.SlideShow();
  262.         try {
  263.             slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("arrowopened.gif"), "");
  264.             slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("circleopened.gif"), "");
  265.             slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("folderopened.gif"), "");
  266.             slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("defaultopened.gif"), "");
  267.         } catch (Exception e) { }
  268.         slideShow2.setBounds(117,12,20,15);
  269.         gbc = new GridBagConstraints();
  270.         gbc.gridx = 2;
  271.         gbc.gridy = 0;
  272.         gbc.weightx = 1.0;
  273.         gbc.weighty = 1.0;
  274.         gbc.anchor = GridBagConstraints.WEST;
  275.         gbc.fill = GridBagConstraints.NONE;
  276.         gbc.insets = new Insets(0,0,0,0);
  277.         ((GridBagLayout)panel5.getLayout()).setConstraints(slideShow2, gbc);
  278.         panel5.add(slideShow2);
  279.         buttonNext = new java.awt.Button();
  280.         buttonNext.setLabel("Next");
  281.         buttonNext.setBounds(161,8,64,23);
  282.         buttonNext.setFont(new Font("Dialog", Font.BOLD, 12));
  283.         buttonNext.setForeground(new Color(255));
  284.         buttonNext.setBackground(new Color(12632256));
  285.         gbc = new GridBagConstraints();
  286.         gbc.gridx = 3;
  287.         gbc.gridy = 0;
  288.         gbc.weightx = 1.0;
  289.         gbc.weighty = 1.0;
  290.         gbc.fill = GridBagConstraints.HORIZONTAL;
  291.         gbc.insets = new Insets(0,0,0,5);
  292.         ((GridBagLayout)panel5.getLayout()).setConstraints(buttonNext, gbc);
  293.         panel5.add(buttonNext);
  294.         label5 = new java.awt.Label("     as its images");
  295.         label5.setBounds(63,289,104,23);
  296.         label5.setFont(new Font("Dialog", Font.PLAIN, 12));
  297.         gbc = new GridBagConstraints();
  298.         gbc.gridx = 0;
  299.         gbc.gridy = 8;
  300.         gbc.weightx = 1.0;
  301.         gbc.weighty = 1.0;
  302.         gbc.fill = GridBagConstraints.NONE;
  303.         gbc.insets = new Insets(0,0,0,0);
  304.         ((GridBagLayout)panel3.getLayout()).setConstraints(label5, gbc);
  305.         panel3.add(label5);
  306.         buttonInsert = new java.awt.Button();
  307.         buttonInsert.setLabel("Insert");
  308.         buttonInsert.setBounds(5,328,221,23);
  309.         buttonInsert.setFont(new Font("Dialog", Font.BOLD, 12));
  310.         buttonInsert.setForeground(new Color(255));
  311.         buttonInsert.setBackground(new Color(12632256));
  312.         gbc = new GridBagConstraints();
  313.         gbc.gridx = 0;
  314.         gbc.gridy = 9;
  315.         gbc.weightx = 1.0;
  316.         gbc.weighty = 1.0;
  317.         gbc.fill = GridBagConstraints.HORIZONTAL;
  318.         gbc.insets = new Insets(0,5,0,5);
  319.         ((GridBagLayout)panel3.getLayout()).setConstraints(buttonInsert, gbc);
  320.         panel3.add(buttonInsert);
  321.         panel4 = new java.awt.Panel();
  322.         gridBagLayout = new GridBagLayout();
  323.         panel4.setLayout(gridBagLayout);
  324.         panel4.setBounds(472,0,236,371);
  325.         panel1.add(panel4);
  326.         panel11 = new java.awt.Panel();
  327.         gridBagLayout = new GridBagLayout();
  328.         panel11.setLayout(gridBagLayout);
  329.         panel11.setBounds(0,5,231,101);
  330.         panel11.setBackground(new Color(16777215));
  331.         gbc = new GridBagConstraints();
  332.         gbc.gridx = 0;
  333.         gbc.gridy = 0;
  334.         gbc.weightx = 1.0;
  335.         gbc.weighty = 1.0;
  336.         gbc.fill = GridBagConstraints.BOTH;
  337.         gbc.insets = new Insets(5,0,0,5);
  338.         ((GridBagLayout)panel4.getLayout()).setConstraints(panel11, gbc);
  339.         panel4.add(panel11);
  340.         panel7 = new java.awt.Panel();
  341.         gridBagLayout = new GridBagLayout();
  342.         panel7.setLayout(gridBagLayout);
  343.         panel7.setBounds(5,0,221,101);
  344.         gbc = new GridBagConstraints();
  345.         gbc.gridx = 0;
  346.         gbc.gridy = 0;
  347.         gbc.weightx = 1.0;
  348.         gbc.weighty = 1.0;
  349.         gbc.fill = GridBagConstraints.BOTH;
  350.         gbc.insets = new Insets(0,5,0,5);
  351.         ((GridBagLayout)panel11.getLayout()).setConstraints(panel7, gbc);
  352.         panel11.add(panel7);
  353.         panel8 = new java.awt.Panel();
  354.         gridBagLayout = new GridBagLayout();
  355.         panel8.setLayout(gridBagLayout);
  356.         panel8.setBounds(0,0,69,101);
  357.         gbc = new GridBagConstraints();
  358.         gbc.gridx = 0;
  359.         gbc.gridy = 0;
  360.         gbc.gridheight = 2;
  361.         gbc.weightx = 1.0;
  362.         gbc.weighty = 1.0;
  363.         gbc.fill = GridBagConstraints.BOTH;
  364.         gbc.insets = new Insets(0,0,0,0);
  365.         ((GridBagLayout)panel7.getLayout()).setConstraints(panel8, gbc);
  366.         panel7.add(panel8);
  367.         label8 = new java.awt.Label("tree color");
  368.         label8.setBounds(0,6,69,23);
  369.         label8.setFont(new Font("Dialog", Font.PLAIN, 12));
  370.         gbc = new GridBagConstraints();
  371.         gbc.gridx = 0;
  372.         gbc.gridy = 0;
  373.         gbc.weightx = 1.0;
  374.         gbc.weighty = 1.0;
  375.         gbc.anchor = GridBagConstraints.WEST;
  376.         gbc.fill = GridBagConstraints.HORIZONTAL;
  377.         gbc.insets = new Insets(0,0,0,0);
  378.         ((GridBagLayout)panel8.getLayout()).setConstraints(label8, gbc);
  379.         panel8.add(label8);
  380.         label9 = new java.awt.Label("status");
  381.         label9.setBounds(0,39,69,23);
  382.         label9.setFont(new Font("Dialog", Font.PLAIN, 12));
  383.         gbc = new GridBagConstraints();
  384.         gbc.gridx = 0;
  385.         gbc.gridy = 1;
  386.         gbc.weightx = 1.0;
  387.         gbc.weighty = 1.0;
  388.         gbc.anchor = GridBagConstraints.WEST;
  389.         gbc.fill = GridBagConstraints.HORIZONTAL;
  390.         gbc.insets = new Insets(0,0,0,0);
  391.         ((GridBagLayout)panel8.getLayout()).setConstraints(label9, gbc);
  392.         panel8.add(label9);
  393.         label7 = new java.awt.Label("# nodes");
  394.         label7.setBounds(0,72,69,23);
  395.         label7.setFont(new Font("Dialog", Font.PLAIN, 12));
  396.         gbc = new GridBagConstraints();
  397.         gbc.gridx = 0;
  398.         gbc.gridy = 2;
  399.         gbc.weightx = 1.0;
  400.         gbc.weighty = 1.0;
  401.         gbc.anchor = GridBagConstraints.WEST;
  402.         gbc.fill = GridBagConstraints.HORIZONTAL;
  403.         gbc.insets = new Insets(0,0,0,0);
  404.         ((GridBagLayout)panel8.getLayout()).setConstraints(label7, gbc);
  405.         panel8.add(label7);
  406.         panel14 = new java.awt.Panel();
  407.         gridBagLayout = new GridBagLayout();
  408.         panel14.setLayout(gridBagLayout);
  409.         panel14.setBounds(69,0,151,101);
  410.         gbc = new GridBagConstraints();
  411.         gbc.gridx = 1;
  412.         gbc.gridy = 0;
  413.         gbc.weightx = 10.0;
  414.         gbc.weighty = 1.0;
  415.         gbc.fill = GridBagConstraints.BOTH;
  416.         gbc.insets = new Insets(0,0,0,0);
  417.         ((GridBagLayout)panel7.getLayout()).setConstraints(panel14, gbc);
  418.         panel7.add(panel14);
  419.         choiceTreeColor = new java.awt.Choice();
  420.         choiceTreeColor.addItem("black");
  421.         choiceTreeColor.addItem("blue");
  422.         choiceTreeColor.addItem("red");
  423.         choiceTreeColor.addItem("green");
  424.         choiceTreeColor.addItem("yellow");
  425.         choiceTreeColor.addItem("orange");
  426.         choiceTreeColor.addItem("purple");
  427.         try {
  428.             choiceTreeColor.select(0);
  429.         }
  430.         catch (IllegalArgumentException e) { }
  431.         choiceTreeColor.setBounds(0,5,151,21);
  432.         choiceTreeColor.setFont(new Font("Dialog", Font.PLAIN, 12));
  433.         gbc = new GridBagConstraints();
  434.         gbc.gridx = 0;
  435.         gbc.gridy = 0;
  436.         gbc.weightx = 1.0;
  437.         gbc.weighty = 1.0;
  438.         gbc.fill = GridBagConstraints.HORIZONTAL;
  439.         gbc.insets = new Insets(0,0,0,0);
  440.         ((GridBagLayout)panel14.getLayout()).setConstraints(choiceTreeColor, gbc);
  441.         panel14.add(choiceTreeColor);
  442.         textFieldStatus = new java.awt.TextField();
  443.         textFieldStatus.setEditable(false);
  444.         textFieldStatus.setText("waiting for input");
  445.         textFieldStatus.setBounds(0,37,151,23);
  446.         textFieldStatus.setFont(new Font("Dialog", Font.PLAIN, 12));
  447.         textFieldStatus.setForeground(new Color(8421504));
  448.         gbc = new GridBagConstraints();
  449.         gbc.gridx = 0;
  450.         gbc.gridy = 1;
  451.         gbc.weightx = 1.0;
  452.         gbc.weighty = 1.0;
  453.         gbc.fill = GridBagConstraints.HORIZONTAL;
  454.         gbc.insets = new Insets(0,0,0,0);
  455.         ((GridBagLayout)panel14.getLayout()).setConstraints(textFieldStatus, gbc);
  456.         panel14.add(textFieldStatus);
  457.         textFieldCount = new java.awt.TextField();
  458.         textFieldCount.setEditable(false);
  459.         textFieldCount.setText("1");
  460.         textFieldCount.setBounds(0,71,151,23);
  461.         textFieldCount.setFont(new Font("Dialog", Font.PLAIN, 12));
  462.         textFieldCount.setForeground(new Color(8421504));
  463.         gbc = new GridBagConstraints();
  464.         gbc.gridx = 0;
  465.         gbc.gridy = 2;
  466.         gbc.weightx = 1.0;
  467.         gbc.weighty = 1.0;
  468.         gbc.fill = GridBagConstraints.HORIZONTAL;
  469.         gbc.insets = new Insets(0,0,0,0);
  470.         ((GridBagLayout)panel14.getLayout()).setConstraints(textFieldCount, gbc);
  471.         panel14.add(textFieldCount);
  472.         panel15 = new java.awt.Panel();
  473.         gridBagLayout = new GridBagLayout();
  474.         panel15.setLayout(gridBagLayout);
  475.         panel15.setBounds(0,111,231,65);
  476.         panel15.setBackground(new Color(16777215));
  477.         gbc = new GridBagConstraints();
  478.         gbc.gridx = 0;
  479.         gbc.gridy = 1;
  480.         gbc.weightx = 1.0;
  481.         gbc.weighty = 1.0;
  482.         gbc.fill = GridBagConstraints.BOTH;
  483.         gbc.insets = new Insets(5,0,5,5);
  484.         ((GridBagLayout)panel4.getLayout()).setConstraints(panel15, gbc);
  485.         panel4.add(panel15);
  486.         buttonNew = new java.awt.Button();
  487.         buttonNew.setLabel("Create New Tree");
  488.         buttonNew.setBounds(5,21,221,23);
  489.         buttonNew.setFont(new Font("Dialog", Font.BOLD, 12));
  490.         buttonNew.setForeground(new Color(-16744320));
  491.         buttonNew.setBackground(new Color(12632256));
  492.         gbc = new GridBagConstraints();
  493.         gbc.gridx = 0;
  494.         gbc.gridy = 0;
  495.         gbc.weightx = 1.0;
  496.         gbc.weighty = 1.0;
  497.         gbc.fill = GridBagConstraints.HORIZONTAL;
  498.         gbc.insets = new Insets(5,5,5,5);
  499.         ((GridBagLayout)panel15.getLayout()).setConstraints(buttonNew, gbc);
  500.         panel15.add(buttonNew);
  501.         panel13 = new java.awt.Panel();
  502.         gridBagLayout = new GridBagLayout();
  503.         panel13.setLayout(gridBagLayout);
  504.         panel13.setBounds(0,181,231,124);
  505.         panel13.setBackground(new Color(16777215));
  506.         gbc = new GridBagConstraints();
  507.         gbc.gridx = 0;
  508.         gbc.gridy = 2;
  509.         gbc.weightx = 1.0;
  510.         gbc.weighty = 1.0;
  511.         gbc.fill = GridBagConstraints.BOTH;
  512.         gbc.insets = new Insets(0,0,0,5);
  513.         ((GridBagLayout)panel4.getLayout()).setConstraints(panel13, gbc);
  514.         panel4.add(panel13);
  515.         label6 = new java.awt.Label("   Delete the first node encountered");
  516.         label6.setBounds(13,4,205,23);
  517.         label6.setFont(new Font("Dialog", Font.PLAIN, 12));
  518.         gbc = new GridBagConstraints();
  519.         gbc.gridx = 0;
  520.         gbc.gridy = 0;
  521.         gbc.weightx = 1.0;
  522.         gbc.weighty = 1.0;
  523.         gbc.fill = GridBagConstraints.NONE;
  524.         gbc.insets = new Insets(0,0,0,0);
  525.         ((GridBagLayout)panel13.getLayout()).setConstraints(label6, gbc);
  526.         panel13.add(label6);
  527.         label10 = new java.awt.Label("   with the following name");
  528.         label10.setBounds(39,35,152,23);
  529.         label10.setFont(new Font("Dialog", Font.PLAIN, 12));
  530.         gbc = new GridBagConstraints();
  531.         gbc.gridx = 0;
  532.         gbc.gridy = 1;
  533.         gbc.weightx = 1.0;
  534.         gbc.weighty = 1.0;
  535.         gbc.fill = GridBagConstraints.NONE;
  536.         gbc.insets = new Insets(0,0,0,0);
  537.         ((GridBagLayout)panel13.getLayout()).setConstraints(label10, gbc);
  538.         panel13.add(label10);
  539.         textFieldDelete = new java.awt.TextField();
  540.         textFieldDelete.setBounds(5,66,221,23);
  541.         textFieldDelete.setFont(new Font("Dialog", Font.PLAIN, 12));
  542.         gbc = new GridBagConstraints();
  543.         gbc.gridx = 0;
  544.         gbc.gridy = 2;
  545.         gbc.weightx = 1.0;
  546.         gbc.weighty = 1.0;
  547.         gbc.fill = GridBagConstraints.HORIZONTAL;
  548.         gbc.insets = new Insets(0,5,0,5);
  549.         ((GridBagLayout)panel13.getLayout()).setConstraints(textFieldDelete, gbc);
  550.         panel13.add(textFieldDelete);
  551.         buttonDelete = new java.awt.Button();
  552.         buttonDelete.setLabel("Delete");
  553.         buttonDelete.setBounds(5,97,221,23);
  554.         buttonDelete.setFont(new Font("Dialog", Font.BOLD, 12));
  555.         buttonDelete.setForeground(new Color(16711680));
  556.         buttonDelete.setBackground(new Color(12632256));
  557.         gbc = new GridBagConstraints();
  558.         gbc.gridx = 0;
  559.         gbc.gridy = 3;
  560.         gbc.weightx = 1.0;
  561.         gbc.weighty = 1.0;
  562.         gbc.fill = GridBagConstraints.HORIZONTAL;
  563.         gbc.insets = new Insets(0,5,0,5);
  564.         ((GridBagLayout)panel13.getLayout()).setConstraints(buttonDelete, gbc);
  565.         panel13.add(buttonDelete);
  566.         panel12 = new java.awt.Panel();
  567.         gridBagLayout = new GridBagLayout();
  568.         panel12.setLayout(gridBagLayout);
  569.         panel12.setBounds(0,310,231,55);
  570.         panel12.setBackground(new Color(16777215));
  571.         gbc = new GridBagConstraints();
  572.         gbc.gridx = 0;
  573.         gbc.gridy = 3;
  574.         gbc.weightx = 1.0;
  575.         gbc.weighty = 1.0;
  576.         gbc.fill = GridBagConstraints.BOTH;
  577.         gbc.insets = new Insets(5,0,5,5);
  578.         ((GridBagLayout)panel4.getLayout()).setConstraints(panel12, gbc);
  579.         panel4.add(panel12);
  580.         buttonDeleteSelected = new java.awt.Button();
  581.         buttonDeleteSelected.setLabel("Delete selected node");
  582.         buttonDeleteSelected.setBounds(5,16,221,23);
  583.         buttonDeleteSelected.setFont(new Font("Dialog", Font.BOLD, 12));
  584.         buttonDeleteSelected.setForeground(new Color(16711680));
  585.         buttonDeleteSelected.setBackground(new Color(12632256));
  586.         gbc = new GridBagConstraints();
  587.         gbc.gridx = 0;
  588.         gbc.gridy = 0;
  589.         gbc.weightx = 1.0;
  590.         gbc.weighty = 1.0;
  591.         gbc.fill = GridBagConstraints.HORIZONTAL;
  592.         gbc.insets = new Insets(0,5,0,5);
  593.         ((GridBagLayout)panel12.getLayout()).setConstraints(buttonDeleteSelected, gbc);
  594.         panel12.add(buttonDeleteSelected);
  595.         //}}
  596.         
  597.         //INITIALIZE THE COUNTER FIELD: used to display the current number of
  598.         //nodes contained by the tree
  599.         textFieldCount.setText("" + treeView1.getCount());   
  600.  
  601.         //LOAD ALL OF THE IMAGES INTO THE APPLET'S MEMORY VIA A MEDIA TRACKER:  If 
  602.         //you don't do it this way, the images of each node will not show up the 
  603.         //first time they are drawn.
  604.         Image tempImage1 = this.getImage(this.getDocumentBase(), "arrowclosed.gif" );
  605.         Image tempImage2 = this.getImage(this.getDocumentBase(), "arrowopened.gif" );
  606.         Image tempImage3 = this.getImage(this.getDocumentBase(), "folderclosed.gif");
  607.         Image tempImage4 = this.getImage(this.getDocumentBase(), "folderopened.gif");
  608.         Image tempImage5 = this.getImage(this.getDocumentBase(), "circleclosed.gif");
  609.         Image tempImage6 = this.getImage(this.getDocumentBase(), "circleopened.gif");
  610.         
  611.         myImageLoader = new MediaTracker(treeView1);
  612.         try{
  613.             myImageLoader.addImage(tempImage1,1);
  614.             myImageLoader.addImage(tempImage2,1);
  615.             myImageLoader.addImage(tempImage3,1);
  616.             myImageLoader.addImage(tempImage4,1);
  617.             myImageLoader.addImage(tempImage5,1);
  618.             myImageLoader.addImage(tempImage6,1);
  619.             myImageLoader.waitForAll();
  620.         }catch (Exception e) {System.out.println(e);}
  621.  
  622.         //{{REGISTER_LISTENERS
  623.         SymAction lSymAction = new SymAction();
  624.         buttonDeleteSelected.addActionListener(lSymAction);
  625.         buttonDelete.addActionListener(lSymAction);
  626.         buttonInsert.addActionListener(lSymAction);
  627.         buttonNext.addActionListener(lSymAction);
  628.         buttonPrevious.addActionListener(lSymAction);
  629.         SymItem lSymItem = new SymItem();
  630.         choiceTreeColor.addItemListener(lSymItem);
  631.         buttonNew.addActionListener(lSymAction);
  632.         //}}
  633.     }
  634.     
  635.     //{{DECLARE_CONTROLS
  636.     java.awt.Panel panel1;
  637.     java.awt.Panel panel2;
  638.     java.awt.Panel panel9;
  639.     symantec.itools.awt.TreeView treeView1;
  640.     java.awt.Panel panel10;
  641.     java.awt.Panel panel3;
  642.     java.awt.Label label3;
  643.     java.awt.TextField textFieldInsert;
  644.     java.awt.Panel panel6;
  645.     java.awt.Label label2;
  646.     java.awt.Checkbox radioButtonChild;
  647.     CheckboxGroup Group1;
  648.     java.awt.Checkbox radioButtonLast;
  649.     java.awt.Checkbox radioButtonNext;
  650.     java.awt.Label label1;
  651.     java.awt.Label label4;
  652.     java.awt.Panel panel5;
  653.     java.awt.Button buttonPrevious;
  654.     symantec.itools.multimedia.SlideShow slideShow1;
  655.     symantec.itools.multimedia.SlideShow slideShow2;
  656.     java.awt.Button buttonNext;
  657.     java.awt.Label label5;
  658.     java.awt.Button buttonInsert;
  659.     java.awt.Panel panel4;
  660.     java.awt.Panel panel11;
  661.     java.awt.Panel panel7;
  662.     java.awt.Panel panel8;
  663.     java.awt.Label label8;
  664.     java.awt.Label label9;
  665.     java.awt.Label label7;
  666.     java.awt.Panel panel14;
  667.     java.awt.Choice choiceTreeColor;
  668.     java.awt.TextField textFieldStatus;
  669.     java.awt.TextField textFieldCount;
  670.     java.awt.Panel panel15;
  671.     java.awt.Button buttonNew;
  672.     java.awt.Panel panel13;
  673.     java.awt.Label label6;
  674.     java.awt.Label label10;
  675.     java.awt.TextField textFieldDelete;
  676.     java.awt.Button buttonDelete;
  677.     java.awt.Panel panel12;
  678.     java.awt.Button buttonDeleteSelected;
  679.     //}}
  680.     
  681.     //THE NEW NODE TO BE INSERTED
  682.     TreeNode newNode;
  683.     //THE CURRENTLY SELECTED NODE
  684.     TreeNode currentNode;
  685.     //THE OPEN AND CLOSED VIEW OF EACH IMAGE
  686.     Image  newNodeOpened, newNodeClosed;
  687.     String openedImageName, closedImageName;
  688.     //MEDIA TRACKER FOR LOADING IN IMAGES ON INITIALIZATION
  689.     MediaTracker myImageLoader;
  690.     
  691.     //BUTTONS: event handler code
  692.     class SymAction implements java.awt.event.ActionListener
  693.     {
  694.         public void actionPerformed(java.awt.event.ActionEvent event)
  695.         {
  696.             Object object = event.getSource();
  697.             if (object == buttonDeleteSelected)
  698.                 buttonDeleteSelected_Action(event);
  699.             else if (object == buttonDelete)
  700.                 buttonDelete_Action(event);
  701.             else if (object == buttonInsert)
  702.                 buttonInsert_Action(event);
  703.             else if (object == buttonNext)
  704.                 buttonNext_Action(event);
  705.             else if (object == buttonPrevious)
  706.                 buttonPrevious_Action(event);
  707.             else if (object == buttonNew)
  708.                 buttonNew_Action(event);
  709.         }
  710.     }
  711.  
  712.     //BUTTON DELETE SELECTED NODE IS CLICKED: Delete the currently
  713.     //selected node.
  714.     void buttonDeleteSelected_Action(java.awt.event.ActionEvent event)
  715.     {
  716.         treeView1.removeSelected();
  717.         treeView1.repaint();
  718.         textFieldCount.setText("" + treeView1.getCount());  
  719.         
  720.         //update the status field
  721.         textFieldStatus.setText("node deleted");
  722.         if (textFieldCount.getText().equals("0")){
  723.             textFieldStatus.setText("press: Create New Tree");
  724.         }
  725.     }
  726.  
  727.     //BUTTON DELETE (SPECIFIC NAMED NODE) IS CLICKED: Delete the node whose
  728.     //name matches that listed in the textFieldDelete text field.
  729.     void buttonDelete_Action(java.awt.event.ActionEvent event)
  730.     {
  731.         treeView1.remove(textFieldDelete.getText());
  732.         treeView1.repaint();
  733.         textFieldCount.setText("" + treeView1.getCount());  
  734.         
  735.         //update the status field
  736.         textFieldStatus.setText("node deleted");
  737.         if (textFieldCount.getText().equals("0")){
  738.             textFieldStatus.setText("press: Create New Tree");
  739.         }
  740.     }
  741.  
  742.     //BUTTON INSERT IS CLICKED: Insert a new node onto the tree
  743.     void buttonInsert_Action(java.awt.event.ActionEvent event)
  744.     {
  745.         //get the image
  746.         updateImage();
  747.         
  748.         newNodeClosed = this.getImage(this.getDocumentBase(), closedImageName);
  749.         newNodeOpened = this.getImage(this.getDocumentBase(), openedImageName);
  750.         
  751.         //get the position
  752.         int selectedRadioButton = 0;
  753.         if (radioButtonChild.getState() == true){ selectedRadioButton = 0; }
  754.         if (radioButtonNext.getState()  == true){ selectedRadioButton = 1; }
  755.         if (radioButtonLast.getState()  == true){ selectedRadioButton = 2; }
  756.  
  757.         //get the label
  758.         String newNodeText   = textFieldInsert.getText();
  759.     
  760.         //do the insert
  761.         newNode = new TreeNode(newNodeText, newNodeClosed, newNodeOpened, treeView1);
  762.         currentNode = treeView1.getSelectedNode();    
  763.         treeView1.insert(newNode, currentNode, selectedRadioButton);     
  764.         treeView1.redraw();
  765.         textFieldCount.setText("" + treeView1.getCount());
  766.         
  767.         //update the status field
  768.         textFieldStatus.setText("node inserted"); 
  769.     }
  770.     
  771.     //HELPER FUNCTION OF INSERT BUTTONS CODE: sets the image pointer
  772.     //used for the new node (openedImageName, closedImageName) to the 
  773.     //appropriat graphic.
  774.     //I also used this function to keep track of the previous and next
  775.     //button's enabled property.  It makes for a better UI to have them
  776.     //disabled when they can't do anything.
  777.     void updateImage()
  778.     {
  779.         int    selectedImage = slideShow1.getCurrentImageIndex();
  780.         
  781.         if (selectedImage == 0){
  782.             openedImageName = "arrowopened.gif";
  783.             closedImageName = "arrowclosed.gif";
  784.             
  785.             //disable the previous button for use
  786.             buttonPrevious.setEnabled(false);
  787.             
  788.         }else if (selectedImage == 1){
  789.             openedImageName = "circleopened.gif";
  790.             closedImageName = "circleclosed.gif";
  791.             
  792.             //enable the previous button for use
  793.             buttonPrevious.setEnabled(true);
  794.             
  795.         }else if (selectedImage == 2){
  796.             openedImageName = "folderopened.gif";
  797.             closedImageName = "folderclosed.gif";
  798.                         
  799.             //enable the next button for use
  800.             buttonNext.setEnabled(true);
  801.           
  802.         }else{
  803.             openedImageName = null;
  804.             closedImageName = null;
  805.             
  806.             //disable the next button for use
  807.             buttonNext.setEnabled(false);
  808.             
  809.         }
  810.     }
  811.  
  812.     //BUTTON NEXT IS CLICKED: go to the next option for
  813.     //node graphics in the slideShow component
  814.     void buttonNext_Action(java.awt.event.ActionEvent event)
  815.     {
  816.         slideShow2.nextImage();
  817.         slideShow1.nextImage();
  818.         updateImage();
  819.         
  820.         //update the status field
  821.         textFieldStatus.setText("choosing image");
  822.     }
  823.  
  824.     //BUTTON PREVIOUS IS CLICKED: go to the previous option for
  825.     //node graphics in the slideShow component
  826.     void buttonPrevious_Action(java.awt.event.ActionEvent event)
  827.     {
  828.         slideShow2.previousImage();
  829.         slideShow1.previousImage();
  830.         updateImage();
  831.         
  832.         //update the status field
  833.         textFieldStatus.setText("choosing image");
  834.     }
  835.  
  836.     //BUTTON NEW IS CLICKED:  Create a new tree
  837.     void buttonNew_Action(java.awt.event.ActionEvent event)
  838.     {
  839.         java.lang.String[] tempString = new java.lang.String[1];
  840.         tempString[0] = new java.lang.String("root");
  841.         treeView1.setTreeStructure(tempString);    
  842.         textFieldCount.setText("" + treeView1.getCount());
  843.         
  844.         //update the status field
  845.         textFieldStatus.setText("new tree created");
  846.     }
  847.  
  848.     //COLOR SELECTED FROM CHOICE BOX: event handler
  849.     class SymItem implements java.awt.event.ItemListener
  850.     {
  851.         public void itemStateChanged(java.awt.event.ItemEvent event)
  852.         {
  853.             Object object = event.getSource();
  854.             if (object == choiceTreeColor)
  855.                 choiceTreeColor_ItemStateChanged(event);
  856.         }
  857.     }
  858.  
  859.     //COLOR SELECTED FROM CHOICE BOX: select the color to display the tree in
  860.     void choiceTreeColor_ItemStateChanged(java.awt.event.ItemEvent event)
  861.     {
  862.         String selectedColor = choiceTreeColor.getSelectedItem();    
  863.  
  864.         if      (selectedColor == "black" ) {treeView1.setForeground(Color.black)  ;}
  865.         else if (selectedColor == "blue"  ) {treeView1.setForeground(Color.blue)   ;}
  866.         else if (selectedColor == "red"   ) {treeView1.setForeground(Color.red)    ;}
  867.         else if (selectedColor == "green" ) {treeView1.setForeground(Color.green)  ;}
  868.         else if (selectedColor == "yellow") {treeView1.setForeground(Color.yellow) ;}
  869.         else if (selectedColor == "orange") {treeView1.setForeground(Color.orange );}
  870.         else if (selectedColor == "purple") {treeView1.setForeground(Color.magenta);}
  871.         treeView1.redraw();
  872.     }
  873.     
  874. }
  875.