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:TreeIconDemo.java

private void createNodes(DefaultMutableTreeNode top) {
    DefaultMutableTreeNode category = null;
    DefaultMutableTreeNode book = null;

    category = new DefaultMutableTreeNode("Books for Java Programmers");
    top.add(category);/*from w  w w.  j  a  v a  2s . c  o m*/

    // original Tutorial
    book = new DefaultMutableTreeNode(
            new BookInfo("The Java Tutorial: A Short Course on the Basics", "tutorial.html"));
    category.add(book);

    // Tutorial Continued
    book = new DefaultMutableTreeNode(
            new BookInfo("The Java Tutorial Continued: The Rest of the JDK", "tutorialcont.html"));
    category.add(book);

    // JFC Swing Tutorial
    book = new DefaultMutableTreeNode(
            new BookInfo("The JFC Swing Tutorial: A Guide to Constructing GUIs", "swingtutorial.html"));
    category.add(book);

    // Bloch
    book = new DefaultMutableTreeNode(new BookInfo("Effective Java Programming Language Guide", "bloch.html"));
    category.add(book);

    // Arnold/Gosling
    book = new DefaultMutableTreeNode(new BookInfo("The Java Programming Language", "arnold.html"));
    category.add(book);

    // Chan
    book = new DefaultMutableTreeNode(new BookInfo("The Java Developers Almanac", "chan.html"));
    category.add(book);

    category = new DefaultMutableTreeNode("Books for Java Implementers");
    top.add(category);

    // VM
    book = new DefaultMutableTreeNode(new BookInfo("The Java Virtual Machine Specification", "vm.html"));
    category.add(book);

    // Language Spec
    book = new DefaultMutableTreeNode(new BookInfo("The Java Language Specification", "jls.html"));
    category.add(book);
}

From source file:de.quadrillenschule.azocamsyncd.gui.ExploreWifiSDPanel.java

private void createSubNodes(DefaultMutableTreeNode parent, LinkedList<AZoFTPFile> afs) {
    String parentNodeName = parent.toString();
    for (AZoFTPFile af : afs) {
        String nodeName = af.dir + af.ftpFile.getName();
        if (af.ftpFile.isDirectory()) {
            if (!parentNodeName.equals(nodeName)) {

                if (nodeName.contains(parentNodeName)) {
                    if (StringUtils.countMatches(nodeName, "/") - 1 == StringUtils.countMatches(parentNodeName,
                            "/")) {
                        DefaultMutableTreeNode tn = new DefaultMutableTreeNode(nodeName);
                        parent.add(tn);//from w w  w .j  av a2s  .com
                        createSubNodes(tn, afs);
                    }
                }
                ;
            }
        }
        //isFile
        if (af.ftpFile.isFile()) {
            if (nodeName.contains(parentNodeName)) {
                if (StringUtils.countMatches(nodeName, "/") == 1
                        + StringUtils.countMatches(parentNodeName, "/")) {
                    DefaultMutableTreeNode tn = new DefaultMutableTreeNode(nodeName);

                    parent.add(tn);

                }
            }
            ;
        }

    }
}

From source file:cloud.gui.CloudGUI.java

private void createELBTab() {
    elbTab = new JPanel();
    elbTab.setLayout(new GridLayout(1, 1));

    DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode("Elastic Load Balancer Table");
    elbTree = new JTree(treeRoot);

    elbTab.add(elbTree);/*from ww  w  .jav a  2s  . com*/
    tabbedPane.addTab("Load Balancer", elbTab);
}

From source file:ClassTree.java

/**
 * Adds a new class and any parent classes that aren't yet part of the tree
 * @param c the class to add/*from  w  ww . j  a va2 s  .  co  m*/
 * @return the newly added node.
 */
public DefaultMutableTreeNode addClass(Class<?> c) {
    // add a new class to the tree

    // skip non-class types
    if (c.isInterface() || c.isPrimitive())
        return null;

    // if the class is already in the tree, return its node
    DefaultMutableTreeNode node = findUserObject(c);
    if (node != null)
        return node;

    // class isn't present--first add class parent recursively

    Class<?> s = c.getSuperclass();

    DefaultMutableTreeNode parent;
    if (s == null)
        parent = root;
    else
        parent = addClass(s);

    // add the class as a child to the parent
    DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(c);
    model.insertNodeInto(newNode, parent, parent.getChildCount());

    // make node visible
    TreePath path = new TreePath(model.getPathToRoot(newNode));
    tree.makeVisible(path);

    return newNode;
}

From source file:gdt.jgui.entity.JEntityDigestDisplay.java

/**
 * Create the context.//from w  ww .java  2 s  . c  o m
 * @param console the main console.
 * @param locator$ the locator.
 * @return the digest display.
 */
@Override
public JContext instantiate(JMainConsole console, String locator$) {
    try {
        this.console = console;
        this.locator$ = locator$;
        Properties locator = Locator.toProperties(locator$);
        entihome$ = locator.getProperty(Entigrator.ENTIHOME);
        entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
        entityLabel$ = locator.getProperty(EntityHandler.ENTITY_LABEL);
        String compressedSelection$ = locator.getProperty(SELECTION);
        if (compressedSelection$ != null) {
            try {
                byte[] ba = Base64.decodeBase64(compressedSelection$);
                selection$ = new String(ba, "UTF-8");
            } catch (Exception ee) {
                Logger.getLogger(getClass().getName()).info(ee.toString());
            }
        }
        Entigrator entigrator = console.getEntigrator(entihome$);
        DefaultMutableTreeNode root = new DefaultMutableTreeNode(entityLabel$);
        locator = new Properties();
        locator.setProperty(Locator.LOCATOR_TITLE, DIGEST);
        String icon$ = Support.readHandlerIcon(null, getClass(), "digest.png");
        locator.setProperty(Locator.LOCATOR_ICON, icon$);
        locator.setProperty(NODE_TYPE, NODE_TYPE_ROOT);
        root.setUserObject(Locator.toString(locator));
        DefaultMutableTreeNode parentNode = new DefaultMutableTreeNode(entityLabel$);
        root.add(parentNode);
        Sack parent = entigrator.getEntityAtKey(entityKey$);
        String parentLocator$ = EntityHandler.getEntityLocator(entigrator, parent);
        parentLocator$ = Locator.append(parentLocator$, NODE_TYPE, NODE_TYPE_PARENT);
        parentNode.setUserObject(parentLocator$);
        tree = new JTree(root);
        tree.addTreeSelectionListener(new SelectionListener());
        tree.setShowsRootHandles(true);
        tree.setCellRenderer(new NodeRenderer());
        tree.addMouseListener(new MousePopupListener());
        scrollPane.getViewport().add(tree);
        facets = listFacetOpenItems();
        DefaultMutableTreeNode[] na = getFacetOpenItems();
        if (na != null)
            for (DefaultMutableTreeNode n : na)
                parentNode.add(n);
        expandTree(tree, true);
        select();
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
    return this;
}

From source file:TreeIconDemo2.java

private void createNodes(DefaultMutableTreeNode top) {
    DefaultMutableTreeNode category = null;
    DefaultMutableTreeNode book = null;

    category = new DefaultMutableTreeNode("Books for Java Programmers");
    top.add(category);/*from  w ww .j  a  va  2 s.c om*/

    //original Tutorial
    book = new DefaultMutableTreeNode(
            new BookInfo("The Java Tutorial: A Short Course on the Basics", "tutorial.html"));
    category.add(book);

    //Tutorial Continued
    book = new DefaultMutableTreeNode(
            new BookInfo("The Java Tutorial Continued: The Rest of the JDK", "tutorialcont.html"));
    category.add(book);

    //JFC Swing Tutorial
    book = new DefaultMutableTreeNode(
            new BookInfo("The JFC Swing Tutorial: A Guide to Constructing GUIs", "swingtutorial.html"));
    category.add(book);

    //Bloch
    book = new DefaultMutableTreeNode(new BookInfo("Effective Java Programming Language Guide", "bloch.html"));
    category.add(book);

    //Arnold/Gosling
    book = new DefaultMutableTreeNode(new BookInfo("The Java Programming Language", "arnold.html"));
    category.add(book);

    //Chan
    book = new DefaultMutableTreeNode(new BookInfo("The Java Developers Almanac", "chan.html"));
    category.add(book);

    category = new DefaultMutableTreeNode("Books for Java Implementers");
    top.add(category);

    //VM
    book = new DefaultMutableTreeNode(new BookInfo("The Java Virtual Machine Specification", "vm.html"));
    category.add(book);

    //Language Spec
    book = new DefaultMutableTreeNode(new BookInfo("The Java Language Specification", "jls.html"));
    category.add(book);
}

From source file:base.BasePlayer.AddGenome.java

static void checkGenomes() {

    //DefaultMutableTreeNode
    File checkdir = Main.genomeDir, checkAnnodir;
    File[] addDir, annodir;//from  w  w  w  .  j a v a2 s  .c om
    root.removeAllChildren();
    int counter = 0;
    for (int i = model.getRowCount() - 1; i >= 0; i--) {
        model.removeRow(i);
    }
    for (int i = remmodel.getRowCount() - 1; i >= 0; i--) {
        remmodel.removeRow(i);
    }

    removables.clear();

    int currentlen = 0, length = 0;
    if (checkdir == null) {
        try {
            checkdir = new File(userDir + "/genomes");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    addDir = checkdir.listFiles();
    for (int f = 0; f < addDir.length; f++) {

        try {
            if (!addDir[f].isDirectory()) {
                continue;
            }
            currentlen = genometable.getFontMetrics(genometable.getFont()).stringWidth(addDir[f].getName());
            if (currentlen > length) {
                length = currentlen;
            }

            AddGenome.removables.add(addDir[f].getName());
            checkAnnodir = new File(checkdir + "/" + addDir[f].getName() + "/annotation/");
            annodir = checkAnnodir.listFiles();
            DefaultMutableTreeNode genome = new DefaultMutableTreeNode(addDir[f].getName());
            root.add(genome);
            if (annodir == null) {
                counter++;
                genome.add(new DefaultMutableTreeNode("Add new annotation..."));
            } else {
                counter += annodir.length + 3;
                for (int a = 0; a < annodir.length; a++) {
                    currentlen = genometable.getFontMetrics(genometable.getFont())
                            .stringWidth(annodir[a].getName());
                    if (currentlen > length) {
                        length = currentlen;
                    }
                    genome.add(new DefaultMutableTreeNode(annodir[a].getName()));
                }
                genome.add(new DefaultMutableTreeNode("Add new annotation..."));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (counter == 0) {
        counter = 1;
        length = genometable.getFontMetrics(genometable.getFont()).stringWidth("Add new annotation...");
    }
    counter++;
    root.add(new DefaultMutableTreeNode("Add new reference..."));
    genometable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    for (int i = 0; i < organisms.size(); i++) {
        if (!AddGenome.removables.contains(organisms.get(i))) {
            Object[] row = { organisms.get(i), "" + sizeHash.get(organisms.get(i))[0] / 1048576 };
            model.addRow(row);
            currentlen = genometable.getFontMetrics(genometable.getFont()).stringWidth(organisms.get(i));
            if (currentlen > length) {
                length = currentlen;
            }
        }
    }

    AddGenome.longestName = length;

    if (genometable.getRowCount() > 15) {
        genometable.setPreferredScrollableViewportSize((new Dimension(
                AddGenome.longestName + 20 + Main.defaultFontSize * 8, genometable.getRowHeight() * 15)));
        genometable.setMinimumSize(new Dimension(AddGenome.longestName + 20, genometable.getRowHeight() * 15));
    } else {
        genometable.setPreferredScrollableViewportSize(
                (new Dimension(AddGenome.longestName + 20 + Main.defaultFontSize * 8,
                        genometable.getRowHeight() * (genometable.getRowCount() + 1))));
        genometable.setMinimumSize(new Dimension(AddGenome.longestName + 20,
                genometable.getRowHeight() * (genometable.getRowCount() + 1)));
    }

    if (remtable.getRowCount() > 15) {
        remtable.setPreferredScrollableViewportSize((new Dimension(
                AddGenome.longestName + 20 + Main.defaultFontSize * 8, remtable.getRowHeight() * 15)));
    } else {
        remtable.setPreferredScrollableViewportSize(
                (new Dimension(AddGenome.longestName + 20 + Main.defaultFontSize * 8,
                        remtable.getRowHeight() * (remtable.getRowCount() + 1))));
    }
    //Main.defaultFontSize = 12;
    genometable.getColumnModel().getColumn(0).setPreferredWidth(AddGenome.longestName + 10);
    genometable.getColumnModel().getColumn(0).setMinWidth(AddGenome.longestName + 10);
    //   genometable.getColumnModel().getColumn(1).setPreferredWidth(Main.defaultFontSize*8);
    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    model.reload();
    int rowheight = tree.getRowHeight();
    if (rowheight < 1) {
        rowheight = Main.defaultFontSize + 4;
    }

    treescroll.setPreferredSize(
            new Dimension(AddGenome.longestName + 20 + Main.defaultFontSize * 8, counter * rowheight));
    treescroll.setMinimumSize(
            new Dimension(AddGenome.longestName + 20 + Main.defaultFontSize * 8, counter * rowheight));
    remscroll.setPreferredSize(
            new Dimension(AddGenome.longestName + 20 + Main.defaultFontSize * 8, counter * rowheight));
    remscroll.setMinimumSize(
            new Dimension(AddGenome.longestName + 20 + Main.defaultFontSize * 8, counter * rowheight));
    tree.expandPath(new TreePath(root));

    setFonts(Main.menuFont);
}

From source file:EditorPaneExample18.java

public EditorPaneExample18() {
    super("JEditorPane Example 18");

    pane = new JEditorPane();
    pane.setEditable(true); // Editable
    getContentPane().add(new JScrollPane(pane), "Center");

    // Add a menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);/*  ww  w  . j a  v  a2  s . co m*/

    // Populate it
    createMenuBar();

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridy = 5;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    editableBox = new JCheckBox("Editable JEditorPane");
    panel.add(editableBox, c);
    editableBox.setSelected(true);
    editableBox.setForeground(typeLabel.getForeground());

    c.gridy = 6;
    c.weightx = 0.0;
    JButton saveButton = new JButton("Save");
    panel.add(saveButton, c);
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            EditorKit kit = pane.getEditorKit();
            try {
                if (kit instanceof RTFEditorKit) {
                    kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength());
                    System.out.flush();
                } else {
                    if (writer == null) {
                        writer = new OutputStreamWriter(System.out);
                        pane.write(writer);
                        writer.flush();
                    }
                    kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength());
                    writer.flush();
                }
            } catch (Exception e) {
                System.out.println("Write failed");
            }
        }
    });

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Register a custom EditorKit for HTML
    ClassLoader loader = getClass().getClassLoader();
    if (loader != null) {
        // Java 2
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit", loader);
    } else {
        // JDK 1.1
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit");
    }

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Change editability based on the checkbox
    editableBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editableBox.isSelected());
            pane.revalidate();
            pane.repaint();
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));

                createMenuBar();
                enableMenuBar(true);
                getRootPane().revalidate();

                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}

From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java

public DefaultMutableTreeNode addNode(QueryMasterData node, DefaultMutableTreeNode parent) {
    DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node);

    QueryMasterData tmpData = new QueryMasterData();
    tmpData.name("working ......");
    tmpData.tooltip("A tmp node");
    tmpData.visualAttribute("LAO");
    DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(tmpData);

    treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
    if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) {
        treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount());
    }/*from www .j ava 2s .c om*/
    //Make sure the user can see the lovely new node.
    jTree1.scrollPathToVisible(new TreePath(childNode.getPath()));

    return childNode;
}

From source file:e3fraud.gui.MainWindow.java

public MainWindow() {
    super(new BorderLayout(5, 5));

    extended = false;//from w w  w  .  j a va  2s  .c o  m

    //Create the log first, because the action listeners
    //need to refer to it.
    log = new JTextArea(10, 50);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    logScrollPane = new JScrollPane(log);
    DefaultCaret caret = (DefaultCaret) log.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    //        create the progress bar
    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(progressBar.getMinimum());
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    //Create the settings pane
    generationSettingLabel = new JLabel("Generate:");
    SpinnerModel collusionsSpinnerModel = new SpinnerNumberModel(1, 0, 3, 1);
    collusionSettingsPanel = new JPanel(new FlowLayout()) {
        @Override
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    // collusionSettingsPanel.setLayout(new BoxLayout(collusionSettingsPanel, BoxLayout.X_AXIS));
    collusionsButton = new JSpinner(collusionsSpinnerModel);
    collusionsLabel = new JLabel("collusion(s)");
    collusionSettingsPanel.add(collusionsButton);
    collusionSettingsPanel.add(collusionsLabel);

    rankingSettingLabel = new JLabel("Rank by:");
    lossButton = new JRadioButton("loss");
    lossButton.setToolTipText("Sort sub-ideal models based on loss for Target of Assessment (high -> low)");
    gainButton = new JRadioButton("gain");
    gainButton.setToolTipText(
            "Sort sub-ideal models based on gain of any actor except Target of Assessment (high -> low)");
    lossGainButton = new JRadioButton("loss + gain");
    lossGainButton.setToolTipText(
            "Sort sub-ideal models based on loss for Target of Assessment and, if equal, on gain of any actor except Target of Assessment");
    //gainLossButton = new JRadioButton("gain + loss");
    lossGainButton.setSelected(true);
    rankingGroup = new ButtonGroup();
    rankingGroup.add(lossButton);
    rankingGroup.add(gainButton);
    rankingGroup.add(lossGainButton);
    //rankingGroup.add(gainLossButton);
    groupingSettingLabel = new JLabel("Group by:");
    groupingButton = new JCheckBox("collusion");
    groupingButton.setToolTipText(
            "Groups sub-ideal models based on the pair of actors colluding before ranking them");
    groupingButton.setSelected(false);
    refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(this);

    settingsPanel = new JPanel();
    settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(generationSettingLabel);
    collusionSettingsPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(collusionSettingsPanel);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    rankingSettingLabel.setAlignmentY(TOP_ALIGNMENT);
    settingsPanel.add(rankingSettingLabel);
    settingsPanel.add(lossButton);
    settingsPanel.add(gainButton);
    settingsPanel.add(lossGainButton);
    //settingsPanel.add(gainLossButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(groupingSettingLabel);
    settingsPanel.add(groupingButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(refreshButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 20)));
    progressBar.setPreferredSize(
            new Dimension(settingsPanel.getSize().width, progressBar.getPreferredSize().height));
    settingsPanel.add(progressBar);

    //Create the result tree
    root = new DefaultMutableTreeNode("No models to display");
    treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel);
    //tree.setUI(new CustomTreeUI());
    tree.setCellRenderer(new CustomTreeCellRenderer(tree));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setLargeModel(true);
    resultScrollPane = new JScrollPane(tree);
    tree.addTreeSelectionListener(treeSelectionListener);

    //tree.setShowsRootHandles(true);
    //Create a file chooser for saving
    sfc = new JFileChooser();
    FileFilter jpegFilter = new FileNameExtensionFilter("JPEG image", new String[] { "jpg", "jpeg" });
    sfc.addChoosableFileFilter(jpegFilter);
    sfc.setFileFilter(jpegFilter);

    //Create a file chooser for loading
    fc = new JFileChooser();
    FileFilter rdfFilter = new FileNameExtensionFilter("RDF file", "RDF");
    fc.addChoosableFileFilter(rdfFilter);
    fc.setFileFilter(rdfFilter);

    //Create the open button.  
    openButton = new JButton("Load model", createImageIcon("images/Open24.png"));
    openButton.addActionListener(this);
    openButton.setToolTipText("Load a e3value model");

    //Create the ideal graph button. 
    idealGraphButton = new JButton("Show ideal graph", createImageIcon("images/Plot.png"));
    idealGraphButton.setToolTipText("Display ideal profitability graph");
    idealGraphButton.addActionListener(this);

    Dimension thinButtonDimension = new Dimension(15, 420);

    //Create the expand subideal graph button. 
    expandButton = new JButton(">");
    expandButton.setPreferredSize(thinButtonDimension);
    expandButton.setMargin(new Insets(0, 0, 0, 0));
    expandButton.setToolTipText("Expand to show non-ideal profitability graph for selected model");
    expandButton.addActionListener(this);

    //Create the collapse sub-ideal graph button. 
    collapseButton = new JButton("<");
    collapseButton.setPreferredSize(thinButtonDimension);
    collapseButton.setMargin(new Insets(0, 0, 0, 0));
    collapseButton.setToolTipText("Collapse non-ideal profitability graph for selected model");
    collapseButton.addActionListener(this);

    //Create the generation button. 
    generateButton = new JButton("Generate sub-ideal models", createImageIcon("images/generate.png"));
    generateButton.addActionListener(this);
    generateButton.setToolTipText("Generate sub-ideal models for the e3value model currently loaded");

    //Create the chart panel
    chartPane = new JPanel();
    chartPane.setLayout(new FlowLayout(FlowLayout.LEFT));
    chartPane.add(expandButton);

    //For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(openButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(20, 0)));
    buttonPanel.add(generateButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPanel.add(idealGraphButton);

    //Add the buttons, the ranking options, the result list and the log to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(settingsPanel, BorderLayout.LINE_START);
    add(resultScrollPane, BorderLayout.CENTER);

    add(logScrollPane, BorderLayout.PAGE_END);
    add(chartPane, BorderLayout.LINE_END);
    //and make a nice border around it
    setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
}