Example usage for javax.swing JPanel setLayout

List of usage examples for javax.swing JPanel setLayout

Introduction

In this page you can find the example usage for javax.swing JPanel setLayout.

Prototype

public void setLayout(LayoutManager mgr) 

Source Link

Document

Sets the layout manager for this container.

Usage

From source file:DiningPhilosophers.java

public void init() {

    imgs[HUNGRYDUKE] = new ImageIcon(getURL("images/hungryduke.gif"));
    imgs[RIGHTSPOONDUKE] = new ImageIcon(getURL("images/rightspoonduke.gif"));
    imgs[BOTHSPOONSDUKE] = new ImageIcon(getURL("images/bothspoonsduke.gif"));

    width = imgs[HUNGRYDUKE].getIconWidth() + (int) (MARGIN * 2.0);
    height = imgs[HUNGRYDUKE].getIconHeight() + (int) (MARGIN * 2.0);
    spacing = width + MARGIN;/*from w w  w  .  j  a v  a  2s  . com*/

    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    JPanel contentPane = new JPanel();
    contentPane.setLayout(gridBag);

    philosopherArea = new JPanel(null);
    philosopherArea.setBackground(Color.white);
    Dimension preferredSize = createPhilosophersAndChopsticks();
    philosopherArea.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    philosopherArea.setPreferredSize(preferredSize);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    gridBag.setConstraints(philosopherArea, c);
    contentPane.add(philosopherArea);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.weighty = 0.0;
    gridBag.setConstraints(stopStartButton, c);
    contentPane.add(stopStartButton);

    c.gridwidth = GridBagConstraints.RELATIVE; //don't end row
    c.weightx = 1.0;
    c.weighty = 0.0;
    gridBag.setConstraints(grabDelaySlider, c);
    contentPane.add(grabDelaySlider);

    c.weightx = 0.0;
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    gridBag.setConstraints(label, c);
    contentPane.add(label);
    contentPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);

    stopStartButton.addActionListener(this);
    grabDelaySlider.addChangeListener(this);

}

From source file:medsavant.uhn.cancer.AddNewCommentDialog.java

private JPanel getMainPanel() {
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    if (selectedOntologyTerm == null) {
        mainPanel.add(getHeader(//ww w . ja  va2 s . c o m
                UserCommentApp.getDefaultOntologyType().name() + " terms associated with this variant"));
        JButton selectNoneButton = new JButton("Clear Selections");
        selectNoneButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                clearSelections();
            }
        });
        mainPanel.add(selectNoneButton);
        mainPanel.add(getOntologyTermsForThisVariant());
        mainPanel.add(getHeader("Comment"));
    } else {
        mainPanel.add(getHeader("Comment for " + UserCommentApp.getDefaultOntologyType().name() + " term "
                + selectedOntologyTerm.getName()));
    }

    commentBox = new JTextArea("", DEFAULT_COMMENTBOX_WIDTH, DEFAULT_COMMENTBOX_HEIGHT);
    commentBox.setLineWrap(true);
    JPanel textBoxPanel = new JPanel();
    textBoxPanel.setLayout(new BoxLayout(textBoxPanel, BoxLayout.X_AXIS));
    textBoxPanel.add(Box.createHorizontalGlue());
    textBoxPanel.add(new JScrollPane(commentBox));
    textBoxPanel.add(Box.createHorizontalGlue());

    mainPanel.add(textBoxPanel);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createHorizontalGlue());
    JButton OKButton = new JButton("OK");
    OKButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                String sessID = LoginController.getSessionID();
                int projId = ProjectController.getInstance().getCurrentProjectID();
                int refId = ReferenceController.getInstance().getCurrentReferenceID();
                UserCommentGroup lcg = MedSavantClient.VariantManager.getUserCommentGroup(sessID, projId, refId,
                        variantRecord);
                if (lcg == null) {
                    lcg = MedSavantClient.VariantManager.createUserCommentGroup(sessID, projId, refId,
                            variantRecord);
                }
                submitComment(lcg);
                dispose();
            } catch (Exception ex) {
                ex.printStackTrace();
                LOG.error("Error: ", ex);
                DialogUtils.displayException("Error", ex.getLocalizedMessage(), ex);
            }
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    buttonPanel.add(OKButton);
    buttonPanel.add(cancelButton);
    buttonPanel.add(Box.createHorizontalGlue());
    mainPanel.add(buttonPanel);
    return mainPanel;
}

From source file:LocationSensitiveDemo.java

public LocationSensitiveDemo() {
    super("Location Sensitive Drag and Drop Demo");

    treeModel = getDefaultTreeModel();/* w  w w .  java  2s  .c  o  m*/
    tree = new JTree(treeModel);
    tree.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.setDropMode(DropMode.ON);
    namesPath = tree.getPathForRow(2);
    tree.expandRow(2);
    tree.expandRow(1);
    tree.setRowHeight(0);

    tree.setTransferHandler(new TransferHandler() {

        public boolean canImport(TransferHandler.TransferSupport info) {
            // for the demo, we'll only support drops (not clipboard paste)
            if (!info.isDrop()) {
                return false;
            }

            String item = (String) indicateCombo.getSelectedItem();

            if (item.equals("Always")) {
                info.setShowDropLocation(true);
            } else if (item.equals("Never")) {
                info.setShowDropLocation(false);
            }

            // we only import Strings
            if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                return false;
            }

            // fetch the drop location
            JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation();

            TreePath path = dl.getPath();

            // we don't support invalid paths or descendants of the names folder
            if (path == null || namesPath.isDescendant(path)) {
                return false;
            }

            return true;
        }

        public boolean importData(TransferHandler.TransferSupport info) {
            // if we can't handle the import, say so
            if (!canImport(info)) {
                return false;
            }

            // fetch the drop location
            JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation();

            // fetch the path and child index from the drop location
            TreePath path = dl.getPath();
            int childIndex = dl.getChildIndex();

            // fetch the data and bail if this fails
            String data;
            try {
                data = (String) info.getTransferable().getTransferData(DataFlavor.stringFlavor);
            } catch (UnsupportedFlavorException e) {
                return false;
            } catch (IOException e) {
                return false;
            }

            // if child index is -1, the drop was on top of the path, so we'll
            // treat it as inserting at the end of that path's list of children
            if (childIndex == -1) {
                childIndex = tree.getModel().getChildCount(path.getLastPathComponent());
            }

            // create a new node to represent the data and insert it into the model
            DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(data);
            DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) path.getLastPathComponent();
            treeModel.insertNodeInto(newNode, parentNode, childIndex);

            // make the new node visible and scroll so that it's visible
            tree.makeVisible(path.pathByAddingChild(newNode));
            tree.scrollRectToVisible(tree.getPathBounds(path.pathByAddingChild(newNode)));

            // demo stuff - remove for blog
            model.removeAllElements();
            model.insertElementAt("String " + (++count), 0);
            // end demo stuff

            return true;
        }
    });

    JList dragFrom = new JList(model);
    dragFrom.setFocusable(false);
    dragFrom.setPrototypeCellValue("String 0123456789");
    model.insertElementAt("String " + count, 0);
    dragFrom.setDragEnabled(true);
    dragFrom.setBorder(BorderFactory.createLoweredBevelBorder());

    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    JPanel wrap = new JPanel();
    wrap.add(new JLabel("Drag from here:"));
    wrap.add(dragFrom);
    p.add(Box.createHorizontalStrut(4));
    p.add(Box.createGlue());
    p.add(wrap);
    p.add(Box.createGlue());
    p.add(Box.createHorizontalStrut(4));
    getContentPane().add(p, BorderLayout.NORTH);

    getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
    indicateCombo = new JComboBox(new String[] { "Default", "Always", "Never" });
    indicateCombo.setSelectedItem("INSERT");

    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    wrap = new JPanel();
    wrap.add(new JLabel("Show drop location:"));
    wrap.add(indicateCombo);
    p.add(Box.createHorizontalStrut(4));
    p.add(Box.createGlue());
    p.add(wrap);
    p.add(Box.createGlue());
    p.add(Box.createHorizontalStrut(4));
    getContentPane().add(p, BorderLayout.SOUTH);

    getContentPane().setPreferredSize(new Dimension(400, 450));
}

From source file:com.sri.ai.praise.demo.ChurchPanel.java

private void initialize() {
    setLayout(new BorderLayout(0, 0));

    JPanel rootPanel = new JPanel();
    add(rootPanel, BorderLayout.CENTER);
    rootPanel.setLayout(new BorderLayout(0, 0));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setContinuousLayout(true);
    splitPane.setResizeWeight(0.5);/*ww w  .j  a va  2s  .c  o m*/
    splitPane.setOneTouchExpandable(true);
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    rootPanel.add(splitPane, BorderLayout.CENTER);

    JPanel churchPanel = new JPanel();
    churchPanel.setLayout(new BorderLayout(0, 0));

    JLabel lblNewLabel = new JLabel("Church Program");
    churchPanel.add(lblNewLabel, BorderLayout.NORTH);

    churchEditor = new ChurchEditor();
    churchPanel.add(churchEditor, BorderLayout.CENTER);

    splitPane.setLeftComponent(churchPanel);

    JPanel hogmPanel = new JPanel();
    hogmPanel.setLayout(new BorderLayout(0, 0));

    JLabel lblNewLabel_1 = new JLabel("Generated Model (Read Only)");
    hogmPanel.add(lblNewLabel_1, BorderLayout.NORTH);

    hogmEditor = new RuleEditor();
    hogmEditor.setEditable(false);
    hogmPanel.add(hogmEditor, BorderLayout.CENTER);

    splitPane.setRightComponent(hogmPanel);
}

From source file:medsavant.uhn.cancer.AddNewCommentDialog.java

private JPanel getOntologyTermsForThisVariant() {
    try {/*from   w w  w  .  ja va  2  s.  c om*/
        JPanel ontologyTermPanel = new JPanel();
        ontologyTermPanel.setLayout(new BoxLayout(ontologyTermPanel, BoxLayout.Y_AXIS));

        String sessID = LoginController.getSessionID();
        String refName = ReferenceController.getInstance().getCurrentReferenceName();
        if (refName == null) {
            DialogUtils.displayError("Error",
                    "Couldn't obtain name of current reference genome - please login again.");
            dispose();
            return null;
        }
        GeneSet geneSet = MedSavantClient.GeneSetManager.getGeneSet(sessID, refName);
        if (geneSet == null) {
            DialogUtils.displayError("Error",
                    "Couldn't find a gene set for reference " + refName + ". Please check project settings.");
            dispose();
            return null;
        }

        Gene[] genesOverlappingVariant = MedSavantClient.GeneSetManager.getGenesInRegion(sessID, geneSet,
                variantRecord.getChrom(), variantRecord.getStartPosition().intValue(),
                variantRecord.getEndPosition().intValue());
        if (genesOverlappingVariant == null || genesOverlappingVariant.length < 1) {
            //TODO: Here we could allow the user to choose from a list of ALL hpo terms, not just those
            //that are already associated with the variant.
            DialogUtils.displayError("No genes were found associated with this variant " + variantRecord
                    + " in geneSet " + geneSet);
            dispose();
            return null;
        }
        Set<OntologyTerm> ontologyTermSet = new TreeSet<OntologyTerm>();
        for (Gene gene : genesOverlappingVariant) {
            OntologyTerm[] ontologyTerms = MedSavantClient.OntologyManager.getTermsForGene(sessID,
                    UserCommentApp.getDefaultOntologyType(), gene.getName());
            if (ontologyTerms != null && ontologyTerms.length > 0) {
                ontologyTermSet.addAll(Arrays.asList(ontologyTerms));
            }
        }

        selectableOntologyTerms = new SelectableOntologyTerm[ontologyTermSet.size()];
        int i = 0;
        for (OntologyTerm ontologyTerm : ontologyTermSet) {
            selectableOntologyTerms[i] = new SelectableOntologyTerm(ontologyTerm);
            ontologyTermPanel.add(selectableOntologyTerms[i]);
            ++i;
        }
        JScrollPane jsp = new JScrollPane(ontologyTermPanel);
        JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        p.setPreferredSize(new Dimension(mainPanelWidth, mainPanelHeight / 2));
        p.add(jsp);
        return p;
    } catch (Exception ex) {
        ex.printStackTrace();
        LOG.error("Error: ", ex);
        DialogUtils.displayException("Error", ex.getMessage(), ex);
        dispose();
        return null;
    }
}

From source file:de.codesourcery.eve.skills.ui.components.impl.ItemBrowserComponent.java

@Override
protected JPanel createPanel() {

    final JPanel result = new JPanel();
    result.setLayout(new GridBagLayout());

    treeModelBuilder = new MarketGroupTreeModelBuilder(dataModel);

    treeModelBuilder.attach(itemTree);// w ww .j a  va2 s.  com

    itemTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            if (e.getPath() != null) {
                treeSelectionChanged((ITreeNode) e.getPath().getLastPathComponent());
            } else {
                treeSelectionChanged(null);
            }
        }
    });

    itemTree.setCellRenderer(new DefaultTreeCellRenderer() {
        public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
            final ITreeNode node = (ITreeNode) value;
            if (node.getValue() instanceof MarketGroup) {
                setText(((MarketGroup) node.getValue()).getName());
            } else if (node.getValue() instanceof InventoryType) {
                setText(((InventoryType) node.getValue()).getName());
            }
            return this;
        };
    });

    // text area
    itemDetails.setLineWrap(true);
    itemDetails.setWrapStyleWord(true);
    itemDetails.setEditable(false);

    // context menu
    final PopupMenuBuilder menuBuilder = new PopupMenuBuilder();
    menuBuilder.addItem("Refine...", new AbstractAction() {

        @Override
        public boolean isEnabled() {
            return getSelectedType() != null && selectionProvider.getSelectedItem() != null;
        }

        private InventoryType getSelectedType() {
            final TreePath selection = itemTree.getSelectionPath();
            if (selection != null && selection.getPathCount() > 0) {
                final ITreeNode node = (ITreeNode) selection.getLastPathComponent();
                if (node.getValue() instanceof InventoryType) {
                    return (InventoryType) node.getValue();
                }
            }
            return null;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            final ICharacter currentCharacter = selectionProvider.getSelectedItem();
            final InventoryType t = getSelectedType();
            if (t != null && currentCharacter != null) {

                final RefiningComponent comp = new RefiningComponent(currentCharacter);
                comp.setModal(true);
                comp.setItemsToRefine(Collections.singletonList(new ItemWithQuantity(getSelectedType(), 1)));
                ComponentWrapper.wrapComponent(comp).setVisible(true);
            }

        }
    });
    menuBuilder.attach(itemTree);

    result.add(new JScrollPane(itemTree), constraints(0, 0).resizeBoth().end());
    result.add(new JScrollPane(itemDetails), constraints(1, 0).resizeBoth().end());
    return result;
}

From source file:drusy.ui.panels.SwitchStatePanel.java

private void addUser(String hostName, String information, long txBytes, long rxBytes) {
    JPanel panel = new JPanel();
    JLabel informationLabel = new JLabel();
    ImageIcon imageIcon;//from   w w w.j a  va  2 s .  co m

    //======== panel1 ========
    {
        panel.setLayout(new BorderLayout());
        panel.setBorder(new EmptyBorder(0, 10, 0, 10));

        //---- label2 ----
        if (hostName.equals("smartphone")) {
            imageIcon = Res.getImage("img/iphone-56.png");
        } else {
            imageIcon = Res.getImage("img/mac-56.png");
        }
        informationLabel.setIcon(imageIcon);
        informationLabel.setText("<html><b>" + information + "</b><br />Download: " + txBytes / 1000.0
                + " ko/s <br />Upload: " + rxBytes / 1000.0 + " ko/s</html>");
        informationLabel.setHorizontalAlignment(SwingConstants.CENTER);
        panel.add(informationLabel, BorderLayout.CENTER);
    }
    mainPanel.add(panel);
    adaptPanelSize();

    users.add(panel);
}

From source file:LDAPTest.java

public LDAPFrame() {
        setTitle("LDAPTest");
        setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

        JPanel northPanel = new JPanel();
        northPanel.setLayout(new java.awt.GridLayout(1, 2, 3, 1));
        northPanel.add(new JLabel("uid", SwingConstants.RIGHT));
        uidField = new JTextField();
        northPanel.add(uidField);/*from ww  w  .j a  v  a2s  .  c o m*/
        add(northPanel, BorderLayout.NORTH);

        JPanel buttonPanel = new JPanel();
        add(buttonPanel, BorderLayout.SOUTH);

        findButton = new JButton("Find");
        findButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                findEntry();
            }
        });
        buttonPanel.add(findButton);

        saveButton = new JButton("Save");
        saveButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                saveEntry();
            }
        });
        buttonPanel.add(saveButton);

        deleteButton = new JButton("Delete");
        deleteButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                deleteEntry();
            }
        });
        buttonPanel.add(deleteButton);

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent event) {
                try {
                    if (context != null)
                        context.close();
                } catch (NamingException e) {
                    e.printStackTrace();
                }
            }
        });
    }

From source file:IDlookGetStream.java

private void buildGUI() {
    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    accountNumberList = new JList();
    loadAccounts();//from  www .ja va  2s  .  c om
    accountNumberList.setVisibleRowCount(2);
    JScrollPane accountNumberListScrollPane = new JScrollPane(accountNumberList);

    //Do Get Account Button
    getAccountButton = new JButton("Get Account");
    getAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                rs.beforeFirst();
                while (rs.next()) {
                    if (rs.getString("acc_id").equals(accountNumberList.getSelectedValue()))
                        break;
                }
                if (!rs.isAfterLast()) {
                    accountIDText.setText(rs.getString("acc_id"));
                    thumbIDText.setText(rs.getString("thumb_id"));
                    Blob blob = rs.getBlob("pic");

                    int b;
                    InputStream bis = rs.getBinaryStream("pic");
                    FileOutputStream f = new FileOutputStream("pic.jpg");
                    while ((b = bis.read()) >= 0) {
                        f.write(b);
                    }
                    f.close();
                    bis.close();

                    icon = new ImageIcon(blob.getBytes(1L, (int) blob.length()));
                    createThumbnail();
                    photographLabel.setIcon(iconThumbnail);
                }
            } catch (Exception selectException) {
                displaySQLErrors(selectException);
            }
        }
    });

    //Do Update Account Button
    updateAccountButton = new JButton("Update Account");
    updateAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                byte[] bytes = new byte[50000];
                FileInputStream fs = new FileInputStream(nailFileText.getText());
                BufferedInputStream bis = new BufferedInputStream(fs);
                bis.read(bytes);

                rs.updateBytes("thumbnail.pic", bytes);
                rs.updateRow();
                bis.close();

                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            } catch (Exception generalE) {
                generalE.printStackTrace();
            }
        }
    });

    //Do insert Account Button
    insertAccountButton = new JButton("Insert Account");
    insertAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                byte[] bytes = new byte[50000];
                FileInputStream fs = new FileInputStream(nailFileText.getText());
                BufferedInputStream bis = new BufferedInputStream(fs);
                bis.read(bytes);

                rs.moveToInsertRow();
                rs.updateInt("thumb_id", Integer.parseInt(thumbIDText.getText()));
                rs.updateInt("acc_id", Integer.parseInt(accountIDText.getText()));
                rs.updateBytes("pic", bytes);
                rs.updateObject("sysobject", null);
                rs.updateTimestamp("ts", new Timestamp(0));
                rs.updateTimestamp("act_ts", new Timestamp(new java.util.Date().getTime()));
                rs.insertRow();
                bis.close();

                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            } catch (Exception generalE) {
                generalE.printStackTrace();
            }
        }
    });

    photographLabel = new JLabel();
    photographLabel.setHorizontalAlignment(JLabel.CENTER);
    photographLabel.setVerticalAlignment(JLabel.CENTER);
    photographLabel.setVerticalTextPosition(JLabel.CENTER);
    photographLabel.setHorizontalTextPosition(JLabel.CENTER);

    JPanel first = new JPanel(new GridLayout(4, 1));
    first.add(accountNumberListScrollPane);
    first.add(getAccountButton);
    first.add(updateAccountButton);
    first.add(insertAccountButton);

    accountIDText = new JTextField(15);
    thumbIDText = new JTextField(15);
    errorText = new JTextArea(5, 15);
    errorText.setEditable(false);

    JPanel second = new JPanel();
    second.setLayout(new GridLayout(2, 1));
    second.add(thumbIDText);
    second.add(accountIDText);

    JPanel third = new JPanel();
    third.add(new JScrollPane(errorText));

    nailFileText = new JTextField(25);

    c.add(first);
    c.add(second);
    c.add(third);
    c.add(nailFileText);
    c.add(photographLabel);

    setSize(500, 500);
    show();
}

From source file:fungus.MycoNodeFrame.java

public MycoNodeFrame(MycoNode node) {
    this.node = node;
    this.setTitle("Node " + node.getID());

    graph = JungGraphObserver.getGraph();

    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    JPanel labelPane = new JPanel();
    labelPane.setLayout(new GridLayout(7, 2));
    JPanel neighborPane = new JPanel();
    neighborPane.setLayout(new BoxLayout(neighborPane, BoxLayout.PAGE_AXIS));
    JPanel logPane = new JPanel();
    logPane.setLayout(new BoxLayout(logPane, BoxLayout.PAGE_AXIS));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    loggingTextArea = new JTextArea("", 25, 100);
    loggingTextArea.setLineWrap(true);//from w w w  .  ja v  a  2  s  .c om
    loggingTextArea.setEditable(false);
    handler = new MycoNodeLogHandler(node, loggingTextArea);
    handler.addChangeListener(this);
    JScrollPane logScrollPane = new JScrollPane(loggingTextArea);
    logScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    logPane.add(logScrollPane);

    contentPane.add(labelPane);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(neighborPane);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(logPane);
    contentPane.add(buttonPane);

    data = node.getHyphaData();
    link = node.getHyphaLink();
    mycocast = node.getMycoCast();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    stateLabel = new JLabel();
    typeLabel = new JLabel();
    queueLengthLabel = new JLabel();
    sameLabel = new JLabel();
    differentLabel = new JLabel();
    maxCapacityLabel = new JLabel();
    idealImmobileLabel = new JLabel();
    idealHyphaeLabel = new JLabel();
    idealBiomassLabel = new JLabel();
    degreeLabel = new JLabel();
    hyphaDegreeLabel = new JLabel();
    biomassDegreeLabel = new JLabel();
    hyphaUtilizationLabel = new JLabel();
    biomassUtilizationLabel = new JLabel();
    capacityUtilizationLabel = new JLabel();

    labelPane.add(new JLabel("state"));
    labelPane.add(stateLabel);
    labelPane.add(new JLabel("type"));
    labelPane.add(typeLabel);
    labelPane.add(new JLabel("queue"));
    labelPane.add(queueLengthLabel);
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel("same"));
    labelPane.add(sameLabel);
    labelPane.add(new JLabel("different"));
    labelPane.add(differentLabel);
    //labelPane.add(new JLabel("immobile"));
    //labelPane.add(idealImmobileLabel);
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel("actual"));
    labelPane.add(new JLabel("ideal"));
    labelPane.add(new JLabel("utilization"));
    labelPane.add(new JLabel("hyphae"));
    labelPane.add(hyphaDegreeLabel);
    labelPane.add(idealHyphaeLabel);
    labelPane.add(hyphaUtilizationLabel);
    labelPane.add(new JLabel("biomass"));
    labelPane.add(biomassDegreeLabel);
    labelPane.add(idealBiomassLabel);
    labelPane.add(biomassUtilizationLabel);
    labelPane.add(new JLabel("capacity"));
    labelPane.add(degreeLabel);
    labelPane.add(maxCapacityLabel);
    labelPane.add(capacityUtilizationLabel);

    neighborListControl = new JList();
    neighborListControl.setLayoutOrientation(JList.VERTICAL_WRAP);
    neighborListControl.setVisibleRowCount(-1);

    neighborListScroller = new JScrollPane(neighborListControl);
    neighborListScroller.setPreferredSize(new Dimension(250, 150));
    neighborListScroller.setMinimumSize(new Dimension(250, 150));

    neighborPane.add(neighborListScroller);

    JButton updateButton = new JButton("Refresh");
    ActionListener updater = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            refreshData();
        }
    };
    updateButton.addActionListener(updater);

    JButton closeButton = new JButton("Close");
    ActionListener closer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeFrame();
        }
    };
    closeButton.addActionListener(closer);

    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(updateButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(closeButton);

    refreshData();

    JungGraphObserver.addChangeListener(this);

    this.pack();
    this.setVisible(true);
}