Example usage for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode

List of usage examples for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode.

Prototype

public DefaultMutableTreeNode(Object userObject) 

Source Link

Document

Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.

Usage

From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java

/** This method is called from within the constructor to
 * initialize the form.//  w ww . j  a v a  2s. c  o m
 */
private void initComponents() {
    jScrollPane1 = new javax.swing.JScrollPane();
    jClearButton = new javax.swing.JButton();
    jConstrainButton = new javax.swing.JButton();
    jExcludeButton = new javax.swing.JButton();
    jOccurrenceButton = new javax.swing.JButton();
    jNameLabel = new javax.swing.JLabel();
    jHintLabel = new javax.swing.JLabel();

    setLayout(null);

    QueryConceptTreeNodeData tmpData = new QueryConceptTreeNodeData();
    tmpData.name("working ......");
    tmpData.tooltip("A root node");
    tmpData.visualAttribute("FAO");
    top = new DefaultMutableTreeNode(tmpData);
    //top = new DefaultMutableTreeNode("Root Node");
    treeModel = new DefaultTreeModel(top);
    //treeModel.addTreeModelListener(new MyTreeModelListener());

    jTree1 = new JTree(treeModel);

    jTree1.setDragEnabled(true);
    jTree1.setEditable(true);
    //jTree1.getSelectionModel().setSelectionMode
    //        (TreeSelectionModel.SINGLE_TREE_SELECTION);
    //jTree1.setShowsRootHandles(true);
    //JScrollPane treeView = new JScrollPane(jTree1);
    jTree1.setRootVisible(false);
    jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree1.setCellRenderer(new MyRenderer());
    ToolTipManager.sharedInstance().registerComponent(jTree1);

    setBorder(javax.swing.BorderFactory.createEtchedBorder());
    add(jScrollPane1);
    //jScrollPane1.setBounds(0, 40, 180, 200);

    jClearButton.setFont(new java.awt.Font("Tahoma", 1, 10));
    jClearButton.setText("X");
    jClearButton.setToolTipText("Clear all items from panel");
    jClearButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jClearButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    jClearButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jClearButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
    }
    jClearButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jClearButtonActionPerformed(evt);
        }
    });

    add(jClearButton);
    jClearButton.setBounds(160, 0, 18, 20);

    jConstrainButton.setText("Dates");
    jConstrainButton.setToolTipText("Constrain group by dates");
    jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    //jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10,-20));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        //jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
    }

    jConstrainButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jConstrainButtonActionPerformed(evt);
        }
    });

    add(jConstrainButton);
    jConstrainButton.setBounds(0, 20, 40, 21);

    jOccurrenceButton.setText("Occurs > 0x");
    jOccurrenceButton.setToolTipText("Set occurrence times");
    jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jOccurrenceButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jOccurrenceButton.setMargin(new java.awt.Insets(-10, -10, -10, -10));
    }
    jOccurrenceButton.setIconTextGap(0);
    jOccurrenceButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jOccurrenceButtonActionPerformed(evt);
        }
    });
    jOccurrenceButton.setBounds(40, 20, 90, 21);
    add(jOccurrenceButton);

    //jExcludeButton.setMnemonic('E');
    jExcludeButton.setText("Exclude");
    jExcludeButton.setToolTipText("Exclude all items in group");
    jExcludeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jExcludeButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jExcludeButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
        jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    }
    jExcludeButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jExcludeButtonActionPerformed(evt);
        }
    });
    add(jExcludeButton);
    jExcludeButton.setBounds(130, 20, 48, 21);

    jNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jNameLabel.setText("Group 1");
    jNameLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jNameLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    add(jNameLabel);
    jNameLabel.setBounds(0, 0, 160, 20);
    jNameLabel.setTransferHandler(new GroupLabelTextHandler());
    jNameLabel.addMouseListener(new DragMouseAdapter());
    jNameLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
        public void mouseMoved(java.awt.event.MouseEvent evt) {
            jNameLabelMouseMoved(evt);
            //System.out.println("mouse x: "+evt.getX()+" y: "+evt.getY());
            //System.out.println("name label x: "+jNameLabel.getX()+" width: "+
            //   jNameLabel.getWidth()+" y: "            
            //   +jNameLabel.getY()+" height "+jNameLabel.getHeight());
        }

    });
    jNameLabel.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseExited(java.awt.event.MouseEvent evt) {
            jNameLabelMouseExited(evt);
        }

    });

    jTree1.addTreeExpansionListener(this);
    jTree1.setTransferHandler(new TextHandler());
    add(jScrollPane1);
    jScrollPane1.setViewportView(jTree1);
    //jTree1.setToolTipText("Double click on a folder to view the items inside");
    //jScrollPane1.getViewport().setToolTipText("Double click on a folder to view the items inside");
    jScrollPane1.setBounds(0, 40, 180, 120);
    //jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    //jTree1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
    //   public void mouseMoved(java.awt.event.MouseEvent evt) {
    //       jScrollPane1MouseMoved(evt);
    //   }

    //@Override
    //public void mouseDragged(MouseEvent e) {
    //    jScrollPane1MouseMoved(e);
    //}

    //});
    //jTree1.addMouseListener(new java.awt.event.MouseAdapter() {
    //   public void mouseExited(java.awt.event.MouseEvent evt) {
    //       jScrollPane1MouseExited(evt);
    //   }

    //@Override
    //public void mouseEntered(MouseEvent e) {

    //    jScrollPane1MouseEntered(e);
    //}

    //});

    jHintLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jHintLabel.setText(
            "<html><center>Drag terms from Navigate, <br>" + "<left>Find and Workplace into this group");
    //jHintLabel.getFont();
    jHintLabel.setFont(new Font("SansSerif", Font.PLAIN, 9));
    //jHintLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    jHintLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jHintLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
    //jHintLabel.setBackground(Color.WHITE);
    //jHintLabel.setForeground(Color.WHITE);
    add(jHintLabel);
    jHintLabel.setBounds(0, 120, 180, 30);
}

From source file:org.jfree.chart.demo.SuperDemo.java

private MutableTreeNode createCombinedAxisChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Combined Axis Charts");
    DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(
            new DemoDescription("CombinedCategoryPlotDemo1", "CombinedCategoryPlotDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode(
            new DemoDescription("CombinedCategoryPlotDemo2", "CombinedCategoryPlotDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode(
            new DemoDescription("CombinedTimeSeriesDemo1", "CombinedTimeSeriesDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode(
            new DemoDescription("CombinedXYPlotDemo1", "CombinedXYPlotDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode5 = new DefaultMutableTreeNode(
            new DemoDescription("CombinedXYPlotDemo2", "CombinedXYPlotDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode6 = new DefaultMutableTreeNode(
            new DemoDescription("CombinedXYPlotDemo3", "CombinedXYPlotDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode7 = new DefaultMutableTreeNode(
            new DemoDescription("CombinedXYPlotDemo4", "CombinedXYPlotDemo4.java"));
    defaultmutabletreenode.add(defaultmutabletreenode1);
    defaultmutabletreenode.add(defaultmutabletreenode2);
    defaultmutabletreenode.add(defaultmutabletreenode3);
    defaultmutabletreenode.add(defaultmutabletreenode4);
    defaultmutabletreenode.add(defaultmutabletreenode5);
    defaultmutabletreenode.add(defaultmutabletreenode6);
    defaultmutabletreenode.add(defaultmutabletreenode7);
    return defaultmutabletreenode;
}

From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java

/**
 * This method is called from within the constructor to initialize the form.
 *//*from w w w  . jav  a2 s  .  co m*/
private void initComponents() {
    jScrollPane1 = new javax.swing.JScrollPane();
    jClearButton = new javax.swing.JButton();
    jConstrainButton = new javax.swing.JButton();
    jExcludeButton = new javax.swing.JButton();
    jOccurrenceButton = new javax.swing.JButton();
    jNameLabel = new javax.swing.JLabel();
    jHintLabel = new javax.swing.JLabel();

    setLayout(null);

    QueryConceptTreeNodeData tmpData = new QueryConceptTreeNodeData();
    tmpData.name("working ......");
    tmpData.tooltip("A root node");
    tmpData.visualAttribute("FAO");
    top = new DefaultMutableTreeNode(tmpData);
    // top = new DefaultMutableTreeNode("Root Node");
    treeModel = new DefaultTreeModel(top);
    // treeModel.addTreeModelListener(new MyTreeModelListener());

    jTree1 = new JTree(treeModel);

    jTree1.setDragEnabled(true);
    jTree1.setEditable(true);
    // jTree1.getSelectionModel().setSelectionMode
    // (TreeSelectionModel.SINGLE_TREE_SELECTION);
    // jTree1.setShowsRootHandles(true);
    // JScrollPane treeView = new JScrollPane(jTree1);
    jTree1.setRootVisible(false);
    jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree1.setCellRenderer(new MyRenderer());
    ToolTipManager.sharedInstance().registerComponent(jTree1);

    setBorder(javax.swing.BorderFactory.createEtchedBorder());
    add(jScrollPane1);
    // jScrollPane1.setBounds(0, 40, 180, 200);

    jClearButton.setFont(new java.awt.Font("Tahoma", 1, 10));
    jClearButton.setText("X");
    jClearButton.setToolTipText("Clear all items from panel");
    jClearButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jClearButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    jClearButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jClearButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
    }
    jClearButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jClearButtonActionPerformed(evt);
        }
    });

    add(jClearButton);
    jClearButton.setBounds(160, 0, 18, 20);

    jConstrainButton.setText("Dates");
    jConstrainButton.setToolTipText("Constrain group by dates");
    jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    // jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10,-20));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        // jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
    }

    jConstrainButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jConstrainButtonActionPerformed(evt);
        }
    });

    add(jConstrainButton);
    jConstrainButton.setBounds(0, 20, 40, 21);

    jOccurrenceButton.setText("Occurs > 0x");
    jOccurrenceButton.setToolTipText("Set occurrence times");
    jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jOccurrenceButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jOccurrenceButton.setMargin(new java.awt.Insets(-10, -10, -10, -10));
    }
    jOccurrenceButton.setIconTextGap(0);
    jOccurrenceButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jOccurrenceButtonActionPerformed(evt);
        }
    });
    jOccurrenceButton.setBounds(40, 20, 90, 21);
    add(jOccurrenceButton);

    // jExcludeButton.setMnemonic('E');
    jExcludeButton.setText("Exclude");
    jExcludeButton.setToolTipText("Exclude all items in group");
    jExcludeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jExcludeButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
    if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
        jExcludeButton.setMargin(new java.awt.Insets(-10, -15, -10, -20));
        jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    }
    jExcludeButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jExcludeButtonActionPerformed(evt);
        }
    });
    add(jExcludeButton);
    jExcludeButton.setBounds(130, 20, 48, 21);

    jNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jNameLabel.setText("Group 1");
    jNameLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jNameLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    add(jNameLabel);
    jNameLabel.setBounds(0, 0, 160, 20);
    jNameLabel.setTransferHandler(new GroupLabelTextHandler());
    jNameLabel.addMouseListener(new DragMouseAdapter());
    jNameLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
        public void mouseMoved(java.awt.event.MouseEvent evt) {
            jNameLabelMouseMoved(evt);
            // System.out.println("mouse x: "+evt.getX()+" y: "+evt.
            // getY());
            // System.out.println("name label x: "+jNameLabel.getX()+
            // " width: "+
            // jNameLabel.getWidth()+" y: "
            // +jNameLabel.getY()+" height "+jNameLabel.getHeight());
        }

    });
    jNameLabel.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseExited(java.awt.event.MouseEvent evt) {
            jNameLabelMouseExited(evt);
        }

    });

    jTree1.addTreeExpansionListener(this);
    jTree1.setTransferHandler(new TextHandler());
    add(jScrollPane1);
    jScrollPane1.setViewportView(jTree1);
    // jTree1.setToolTipText(
    // "Double click on a folder to view the items inside");
    // jScrollPane1.getViewport().setToolTipText(
    // "Double click on a folder to view the items inside");
    jScrollPane1.setBounds(0, 40, 180, 120);
    // jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new
    // java.awt.Color(0, 0, 0)));
    // jTree1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter()
    // {
    // public void mouseMoved(java.awt.event.MouseEvent evt) {
    // jScrollPane1MouseMoved(evt);
    // }

    // @Override
    // public void mouseDragged(MouseEvent e) {
    // jScrollPane1MouseMoved(e);
    // }

    // });
    // jTree1.addMouseListener(new java.awt.event.MouseAdapter() {
    // public void mouseExited(java.awt.event.MouseEvent evt) {
    // jScrollPane1MouseExited(evt);
    // }

    // @Override
    // public void mouseEntered(MouseEvent e) {

    // jScrollPane1MouseEntered(e);
    // }

    // });

    jHintLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jHintLabel.setText(
            "<html><center>Drag terms from Navigate, <br>" + "<left>Find and Workplace into this group");
    // jHintLabel.getFont();
    jHintLabel.setFont(new Font("SansSerif", Font.PLAIN, 9));
    // jHintLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    jHintLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jHintLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
    // jHintLabel.setBackground(Color.WHITE);
    // jHintLabel.setForeground(Color.WHITE);
    add(jHintLabel);
    jHintLabel.setBounds(0, 120, 180, 30);
}

From source file:org.jfree.chart.demo.SuperDemo.java

private MutableTreeNode createGanttChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Gantt Charts");
    DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(
            new DemoDescription("GanttDemo1", "GanttDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode(
            new DemoDescription("GanttDemo2", "GanttDemo2.java"));
    defaultmutabletreenode.add(defaultmutabletreenode1);
    defaultmutabletreenode.add(defaultmutabletreenode2);
    return defaultmutabletreenode;
}

From source file:GUI.MainWindow.java

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed

    // Create a new vuln
    Vulnerability vuln = new Vulnerability();
    vuln.setTitle("NEW");
    vuln.setIs_custom_risk(true);/* ww  w .  j a  v a2s  . c  o  m*/
    vuln.setRisk_category("None");
    vuln.setImport_tool("ReportCompiler");
    vuln.setIdentifier();
    // Add it to the tree
    DefaultTreeModel dtm = (DefaultTreeModel) VulnTree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) dtm.getRoot();
    DefaultMutableTreeNode new_vuln = new DefaultMutableTreeNode(vuln);
    root.add(new_vuln);
    // Refresh the GUI
    dtm.reload();
    // Now select 
    TreePath path = new TreePath(new_vuln.getPath());
    VulnTree.setSelectionPath(path);
    // Set focus on the title field
    this.VulnTitleTextField.requestFocus();
    this.VulnTitleTextField.selectAll();
}

From source file:org.jfree.chart.demo.SuperDemo.java

private MutableTreeNode createMiscellaneousChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Miscellaneous");
    DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(
            new DemoDescription("BubbleChartDemo1", "BubbleChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode(
            new DemoDescription("BubbleChartDemo2", "BubbleChartDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode(
            new DemoDescription("CategoryLabelPositionsDemo1", "CategoryLabelPositionsDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode(
            new DemoDescription("CategoryStepChartDemo1", "CategoryStepChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode5 = new DefaultMutableTreeNode(
            new DemoDescription("CompassDemo1", "CompassDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode6 = new DefaultMutableTreeNode(
            new DemoDescription("CompassFormatDemo1", "CompassFormatDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode7 = new DefaultMutableTreeNode(
            new DemoDescription("CompassFormatDemo2", "CompassFormatDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode8 = new DefaultMutableTreeNode(
            new DemoDescription("DifferenceChartDemo1", "DifferenceChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode9 = new DefaultMutableTreeNode(
            new DemoDescription("DifferenceChartDemo2", "DifferenceChartDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode10 = new DefaultMutableTreeNode(
            new DemoDescription("EventFrequencyDemo1", "EventFrequencyDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode11 = new DefaultMutableTreeNode(
            new DemoDescription("GradientPaintTransformerDemo1", "GradientPaintTransformerDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode12 = new DefaultMutableTreeNode(
            new DemoDescription("GridBandDemo1", "GridBandDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode13 = new DefaultMutableTreeNode(
            new DemoDescription("HideSeriesDemo1", "HideSeriesDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode14 = new DefaultMutableTreeNode(
            new DemoDescription("HideSeriesDemo2", "HideSeriesDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode15 = new DefaultMutableTreeNode(
            new DemoDescription("HideSeriesDemo3", "HideSeriesDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode16 = new DefaultMutableTreeNode(
            new DemoDescription("MultipleDatasetDemo1", "MultipleDatasetDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode17 = new DefaultMutableTreeNode(
            new DemoDescription("PolarChartDemo1", "PolarChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode18 = new DefaultMutableTreeNode(
            new DemoDescription("SpiderWebChartDemo1", "SpiderWebChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode19 = new DefaultMutableTreeNode(
            new DemoDescription("SymbolAxisDemo1", "SymbolAxisDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode20 = new DefaultMutableTreeNode(
            new DemoDescription("ThermometerDemo1", "ThermometerDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode21 = new DefaultMutableTreeNode(
            new DemoDescription("ThermometerDemo2", "ThermometerDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode22 = new DefaultMutableTreeNode(
            new DemoDescription("TranslateDemo1", "TranslateDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode23 = new DefaultMutableTreeNode(
            new DemoDescription("YIntervalChartDemo1", "YIntervalChartDemo1.java"));
    defaultmutabletreenode.add(createAnnotationsNode());
    defaultmutabletreenode.add(createCrosshairChartsNode());
    defaultmutabletreenode.add(createDynamicChartsNode());
    defaultmutabletreenode.add(createItemLabelsNode());
    defaultmutabletreenode.add(createLegendNode());
    defaultmutabletreenode.add(createMarkersNode());
    defaultmutabletreenode.add(createOrientationNode());
    defaultmutabletreenode.add(defaultmutabletreenode1);
    defaultmutabletreenode.add(defaultmutabletreenode2);
    defaultmutabletreenode.add(defaultmutabletreenode3);
    defaultmutabletreenode.add(defaultmutabletreenode4);
    defaultmutabletreenode.add(defaultmutabletreenode5);
    defaultmutabletreenode.add(defaultmutabletreenode6);
    defaultmutabletreenode.add(defaultmutabletreenode7);
    defaultmutabletreenode.add(defaultmutabletreenode8);
    defaultmutabletreenode.add(defaultmutabletreenode9);
    defaultmutabletreenode.add(defaultmutabletreenode10);
    defaultmutabletreenode.add(defaultmutabletreenode11);
    defaultmutabletreenode.add(defaultmutabletreenode12);
    defaultmutabletreenode.add(defaultmutabletreenode13);
    defaultmutabletreenode.add(defaultmutabletreenode14);
    defaultmutabletreenode.add(defaultmutabletreenode15);
    defaultmutabletreenode.add(defaultmutabletreenode16);
    defaultmutabletreenode.add(defaultmutabletreenode17);
    defaultmutabletreenode.add(defaultmutabletreenode18);
    defaultmutabletreenode.add(defaultmutabletreenode19);
    defaultmutabletreenode.add(defaultmutabletreenode20);
    defaultmutabletreenode.add(defaultmutabletreenode21);
    defaultmutabletreenode.add(defaultmutabletreenode22);
    defaultmutabletreenode.add(defaultmutabletreenode23);
    return defaultmutabletreenode;
}

From source file:it.cnr.icar.eric.client.ui.swing.graph.JBGraph.java

/**
 * DOCUMENT ME!/*from   ww  w  .  j ava2s.  co  m*/
 *
 * @return DOCUMENT ME!
 */
public JToolBar createToolBar() {
    JButton button = null;
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);

    //TODO: SwingBoost: Localize this
    TreeNode tempTreeNode = new DefaultMutableTreeNode("loading object types...");
    objectTypeCombo = new it.cnr.icar.eric.client.ui.swing.TreeCombo(new DefaultTreeModel(tempTreeNode));
    toolbar.add(objectTypeCombo);

    // use a SwingWorker to get the real model, since it might not have been initialized yet
    final SwingWorker worker = new SwingWorker(this) {
        public Object doNonUILogic() {
            ConceptsTreeModel objectTypesTreeModel = BusinessQueryPanel.getObjectTypesTreeModel();
            return objectTypesTreeModel;
        }

        public void doUIUpdateLogic() {
            ConceptsTreeModel objectTypesTreeModel = (ConceptsTreeModel) get();
            objectTypeCombo.setModel(objectTypesTreeModel);
        }
    };
    worker.start();

    // Insert
    URL insertUrl = getClass().getClassLoader().getResource("icons/insert.gif");
    ImageIcon insertIcon = new ImageIcon(insertUrl);
    button = toolbar.add(new AbstractAction("", insertIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            insert(new Point(10, 10));
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Insert");

    // Toggle Connect Mode
    URL connectUrl = getClass().getClassLoader().getResource("icons/connecton.gif");
    ImageIcon connectIcon = new ImageIcon(connectUrl);
    button = toolbar.add(new AbstractAction("", connectIcon) {

        /**
        * 
        */
        private static final long serialVersionUID = 657528648199915209L;

        public void actionPerformed(ActionEvent e) {
            setPortsVisible(!isPortsVisible());

            URL connectUrl;

            if (isPortsVisible()) {
                connectUrl = getClass().getClassLoader().getResource("icons/connecton.gif");
            } else {
                connectUrl = getClass().getClassLoader().getResource("icons/connectoff.gif");
            }

            ImageIcon connectIcon = new ImageIcon(connectUrl);
            putValue(SMALL_ICON, connectIcon);
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Toggle Connect Mode");

    // Undo
    toolbar.addSeparator();

    URL undoUrl = getClass().getClassLoader().getResource("icons/undo.gif");
    ImageIcon undoIcon = new ImageIcon(undoUrl);
    undo = new AbstractAction("", undoIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -740055667372297781L;

        public void actionPerformed(ActionEvent e) {
            undo();
        }
    };
    undo.setEnabled(false);
    button = toolbar.add(undo);
    button.setText(""); //an icon-only button
    button.setToolTipText("Undo");

    // Redo
    URL redoUrl = getClass().getClassLoader().getResource("icons/redo.gif");
    ImageIcon redoIcon = new ImageIcon(redoUrl);
    redo = new AbstractAction("", redoIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 5021485220988522968L;

        public void actionPerformed(ActionEvent e) {
            redo();
        }
    };
    redo.setEnabled(false);
    button = toolbar.add(redo);
    button.setText(""); //an icon-only button
    button.setToolTipText("Redo");

    //
    // Edit Block
    //
    toolbar.addSeparator();

    Action action;
    URL url;

    // Copy
    action = TransferHandler.getCopyAction();
    url = getClass().getClassLoader().getResource("icons/copy.gif");
    action.putValue(Action.SMALL_ICON, new ImageIcon(url));

    //Commented out until we can figure out how to assign new id to copied objects
    //button = toolbar.add(copy = new EventRedirector(action));
    button.setText(""); //an icon-only button
    button.setToolTipText("Copy");

    // Paste
    action = TransferHandler.getPasteAction();
    url = getClass().getClassLoader().getResource("icons/paste.gif");
    action.putValue(Action.SMALL_ICON, new ImageIcon(url));

    //Commented out until we can figure out how to assign new id to copied objects
    //button = toolbar.add(paste = new EventRedirector(action));
    button.setText(""); //an icon-only button
    button.setToolTipText("Paste");

    // Cut
    action = TransferHandler.getCutAction();
    url = getClass().getClassLoader().getResource("icons/cut.gif");
    action.putValue(Action.SMALL_ICON, new ImageIcon(url));

    //Commented out until we can figure out how to assign new id to copied objects
    //button = toolbar.add(cut = new EventRedirector(action));
    button.setText(""); //an icon-only button
    button.setToolTipText("Cut");

    // Remove
    URL removeUrl = getClass().getClassLoader().getResource("icons/delete.gif");
    ImageIcon removeIcon = new ImageIcon(removeUrl);
    remove = new AbstractAction("", removeIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 6889927067487680474L;

        public void actionPerformed(ActionEvent e) {
            if (!isSelectionEmpty()) {
                Object[] cells = getSelectionCells();
                cells = getDescendants(cells);
                getModel().remove(cells);

                //Remove entry from map of cells on the graph
                for (int i = 0; i < cells.length; i++) {
                    Object cell = cells[i];

                    if (cell instanceof JBGraphCell) {
                        RegistryObject ro = ((JBGraphCell) cell).getRegistryObject();
                        registryObjectToCellMap.remove(ro);
                    }
                }
            }
        }
    };
    remove.setEnabled(false);
    button = toolbar.add(remove);
    button.setText(""); //an icon-only button
    button.setToolTipText(resourceBundle.getString("menu.graphPanel.removeFromView"));

    // Zoom Std
    toolbar.addSeparator();

    URL zoomUrl = getClass().getClassLoader().getResource("icons/zoom.gif");
    ImageIcon zoomIcon = new ImageIcon(zoomUrl);
    button = toolbar.add(new AbstractAction("", zoomIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -4404610379022823602L;

        public void actionPerformed(ActionEvent e) {
            setScale(1.0);
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Zoom");

    // Zoom In
    URL zoomInUrl = getClass().getClassLoader().getResource("icons/zoomin.gif");
    ImageIcon zoomInIcon = new ImageIcon(zoomInUrl);
    button = toolbar.add(new AbstractAction("", zoomInIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 6782766891458235321L;

        public void actionPerformed(ActionEvent e) {
            setScale(2 * getScale());
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Zoom In");

    // Zoom Out
    URL zoomOutUrl = getClass().getClassLoader().getResource("icons/zoomout.gif");
    ImageIcon zoomOutIcon = new ImageIcon(zoomOutUrl);
    button = toolbar.add(new AbstractAction("", zoomOutIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -5480242207934335070L;

        public void actionPerformed(ActionEvent e) {
            setScale(getScale() / 2);
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Zoom Out");

    // Group
    /*
    toolbar.addSeparator();
            
    URL groupUrl          =
    getClass().getClassLoader().getResource("icons/group.gif");
    ImageIcon groupIcon   = new ImageIcon(groupUrl);
    group =
    new AbstractAction("", groupIcon) {
            public void actionPerformed(ActionEvent e) {
                group(getSelectionCells());
            }
        };
    group.setEnabled(false);
    //button                = toolbar.add(group);
    button.setText(""); //an icon-only button
    button.setToolTipText("Group");
            
    // Ungroup
    URL ungroupUrl        =
    getClass().getClassLoader().getResource("icons/ungroup.gif");
    ImageIcon ungroupIcon = new ImageIcon(ungroupUrl);
    ungroup =
    new AbstractAction("", ungroupIcon) {
            public void actionPerformed(ActionEvent e) {
                ungroup(getSelectionCells());
            }
        };
    ungroup.setEnabled(false);
    //button                = toolbar.add(ungroup);
    button.setText(""); //an icon-only button
    button.setToolTipText("Ungroup");
     */
    // To Front
    toolbar.addSeparator();

    URL toFrontUrl = getClass().getClassLoader().getResource("icons/tofront.gif");
    ImageIcon toFrontIcon = new ImageIcon(toFrontUrl);
    tofront = new AbstractAction("", toFrontIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -4901428890590828561L;

        public void actionPerformed(ActionEvent e) {
            if (!isSelectionEmpty()) {
                toFront(getSelectionCells());
            }
        }
    };
    tofront.setEnabled(false);
    button = toolbar.add(tofront);
    button.setText(""); //an icon-only button
    button.setToolTipText("To Front");

    // To Back
    URL toBackUrl = getClass().getClassLoader().getResource("icons/toback.gif");
    ImageIcon toBackIcon = new ImageIcon(toBackUrl);
    toback = new AbstractAction("", toBackIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -5942025518651424307L;

        public void actionPerformed(ActionEvent e) {
            if (!isSelectionEmpty()) {
                toBack(getSelectionCells());
            }
        }
    };
    toback.setEnabled(false);
    button = toolbar.add(toback);
    button.setText(""); //an icon-only button
    button.setToolTipText("To Back");

    return toolbar;
}

From source file:lcmc.gui.ClusterBrowser.java

/** Updates common block devices. */
public void updateCommonBlockDevices() {
    if (commonBlockDevicesNode != null) {
        DefaultMutableTreeNode resource;
        final List<String> bd = cluster.getCommonBlockDevices();
        @SuppressWarnings("unchecked")
        final Enumeration<DefaultMutableTreeNode> e = commonBlockDevicesNode.children();
        final List<DefaultMutableTreeNode> nodesToRemove = new ArrayList<DefaultMutableTreeNode>();
        while (e.hasMoreElements()) {
            final DefaultMutableTreeNode node = e.nextElement();
            final Info cbdi = (Info) node.getUserObject();
            if (bd.contains(cbdi.getName())) {
                /* keeping */
                bd.remove(bd.indexOf(cbdi.getName()));
            } else {
                /* remove not existing block devices */
                cbdi.setNode(null);// w  ww . j a v a  2  s  .  co  m
                nodesToRemove.add(node);
            }
        }

        /* remove nodes */
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                for (DefaultMutableTreeNode node : nodesToRemove) {
                    node.removeFromParent();
                }
            }
        });

        /* block devices */
        for (String device : bd) {
            /* add new block devices */
            resource = new DefaultMutableTreeNode(
                    new CommonBlockDevInfo(device, cluster.getHostBlockDevices(device), this));
            setNode(resource);
            addNode(commonBlockDevicesNode, resource);
        }
        if (!bd.isEmpty() || !nodesToRemove.isEmpty()) {
            reload(commonBlockDevicesNode, false);
            reloadAllComboBoxes(null);
        }
    }
}

From source file:eu.crisis_economics.abm.dashboard.GASearchHandler.java

protected DefaultMutableTreeNode getAlteredParameterTreeRootNode(final IIntelliContext ctx) {
    genotype = generateInitialPopulation(ctx);

    final Population descendants = genotype.getPopulation();
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode("Parameter file");

    paramList = ctx.getParameters();/*from  w ww .ja  va 2s . c om*/
    for (int i = 0; i < paramList.size(); ++i) {
        final ParameterInfo paramInfo = paramList.get(i);
        paramInfo.setRuns(1); // Run is always 1

        final List<Object> values = new ArrayList<Object>();

        final int genIdx = whichGene(calculateName(paramInfo));
        for (int j = 0; j < populationSize; ++j) {
            if (genIdx >= 0) {
                final String strValue = String
                        .valueOf(descendants.getChromosome(j).getGene(genIdx).getAllele());
                values.add(ParameterInfo.getValue(strValue, paramInfo.getType()));
                paramInfo.setDefinitionType(ParameterInfo.LIST_DEF);
            } else {
                values.add(paramInfo.getValue());
                paramInfo.setDefinitionType(ParameterInfo.CONST_DEF);
            }
        }

        paramInfo.setValues(values);

        // add and save the node
        root.add(new DefaultMutableTreeNode(paramInfo));
    }

    return root;
}

From source file:lcmc.gui.ClusterBrowser.java

/** Updates available services. */
private void updateAvailableServices() {
    DefaultMutableTreeNode resource;
    Tools.debug(this, "update available services");
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            availableServicesNode.removeAllChildren();
        }// w  w  w . ja v a 2  s  .  c o  m
    });
    for (final String cl : HB_CLASSES) {
        final ResourceAgentClassInfo raci = new ResourceAgentClassInfo(cl, this);
        classInfoMap.put(cl, raci);
        final DefaultMutableTreeNode classNode = new DefaultMutableTreeNode(raci);
        for (final ResourceAgent ra : crmXML.getServices(cl)) {
            final AvailableServiceInfo asi = new AvailableServiceInfo(ra, this);
            availableServiceMap.put(ra, asi);
            resource = new DefaultMutableTreeNode(asi);
            setNode(resource);
            addNode(classNode, resource);
        }
        setNode(classNode);
        addNode(availableServicesNode, classNode);
    }
}