Example usage for javax.swing JButton setText

List of usage examples for javax.swing JButton setText

Introduction

In this page you can find the example usage for javax.swing JButton setText.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The button's text.")
public void setText(String text) 

Source Link

Document

Sets the button's text.

Usage

From source file:DateChooserPanel.java

/**
 * Update the button labels and colors to reflect date selection.
 *///from  w ww  . j  a  v a2  s.  co  m
private void refreshButtons() {
    final Calendar c = getFirstVisibleDate();
    for (int i = 0; i < 42; i++) {
        final JButton b = this.buttons[i];
        b.setText(Integer.toString(c.get(Calendar.DATE)));
        b.setBackground(getButtonColor(c));
        c.add(Calendar.DATE, 1);
    }
}

From source file:de.ipk_gatersleben.ag_nw.graffiti.services.GUIhelper.java

public static JComponent getWebsiteDownloadButton(final String title, final String optUrlManualDownloadWebsite,
        final String target_dir_null_ask_user, final String optIntroText, final String[] downloadURLs,
        final String optIntroDialogTitle, final FileDownloadStatusInformationProvider statusProvider,
        final Runnable optFinishSwingTask) {

    final JButton res = new JMButton("Download/Update");
    res.setToolTipText(//from ww w . j  av  a2s  . c o m
            "<html>Click button to start automatic download<br><code><b>Check License/Disclaimers first!");
    res.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            final String opt_local_folder;
            if (target_dir_null_ask_user == null) {
                File file = OpenFileDialogService.getDirectoryFromUser("Select folder");
                if (file == null)
                    return;
                else
                    opt_local_folder = file.getAbsolutePath();
            } else {
                opt_local_folder = target_dir_null_ask_user;
            }

            res.setEnabled(false);
            res.setText("Downloading");
            final BackgroundTaskStatusProviderSupportingExternalCallImpl status = new BackgroundTaskStatusProviderSupportingExternalCallImpl(
                    "Please wait...", "Downloading files...");
            BackgroundTaskHelper.issueSimpleTask(title, "Please wait...", new Runnable() {
                public void run() {
                    boolean allOK = true;
                    for (String downloadURL : downloadURLs) {
                        allOK = performDownload(downloadURL, opt_local_folder, status);
                        if (status.wantsToStop()) {
                            break;
                        }
                    }
                    if (status.wantsToStop()) {
                        allOK = true;
                        try {
                            status.setCurrentStatusText1("Cancel...");
                            for (String downloadURL : downloadURLs) {
                                String fileName = downloadURL.substring(downloadURL.lastIndexOf("/") + 1);
                                if (downloadURL.contains("|"))
                                    fileName = downloadURL.substring(downloadURL.lastIndexOf("|") + 1);
                                String targetFileName = ReleaseInfo.getAppFolderWithFinalSep() + fileName;
                                if (new File(targetFileName).exists()) {
                                    new File(targetFileName).delete();
                                    status.setCurrentStatusText2("Delete " + targetFileName);
                                }
                            }
                        } catch (Exception e) {
                            //
                        }
                    }

                    if (!allOK) {
                        res.setEnabled(true);
                        res.setText(
                                "<html><small>Automatic download failure<br>Click here for manual download");
                        res.removeActionListener(res.getActionListeners()[0]);
                        res.addActionListener(getDialogAction(optUrlManualDownloadWebsite, opt_local_folder,
                                optIntroText, optIntroDialogTitle));
                        res.requestFocus();
                        final JDialog jd = (JDialog) ErrorMsg.findParentComponent(res, JDialog.class);
                        if (jd != null) {
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run() {
                                    jd.pack();
                                }
                            });
                        }
                    } else {
                        if (status.wantsToStop()) {
                            res.setText("Canceled");
                            status.pleaseContinueRun();
                            status.setCurrentStatusText2("Canceled!");
                        } else {
                            res.setText("Downloaded");
                        }
                        res.setEnabled(false);
                        if (statusProvider != null)
                            statusProvider.finishedNewDownload();
                        if (optFinishSwingTask != null)
                            SwingUtilities.invokeLater(optFinishSwingTask);
                    }
                }
            }, null, status);
        }
    });
    return res;
}

From source file:com.intuit.tank.proxy.ProxyApp.java

private JButton createButton(Action a) {
    JButton ret = new JButton(a);
    ret.setText("");
    ret.setMargin(new Insets(3, 3, 3, 3));
    // ret.setIcon((Icon) a.getValue(Action.SMALL_ICON_KEY));
    return ret;//from  w w w.  java  2 s .c  om

}

From source file:org.drugis.addis.gui.builder.NetworkMetaAnalysisView.java

private JComponent buildNodeSplitControls() {
    final FormLayout layout = new FormLayout("fill:0:grow, 3dlu, pref", "p");
    final CellConstraints cc = new CellConstraints();
    final PanelBuilder panelBuilder = new PanelBuilder(layout);

    final JButton resetAll = new JButton(
            MainWindow.IMAGELOADER.getIcon(org.drugis.mtc.gui.FileNames.ICON_REDO));
    resetAll.setToolTipText("Reset all simulations");
    resetAll.addActionListener(new ActionListener() {
        @Override//from   ww w . j a  v a  2s  .co m
        public void actionPerformed(final ActionEvent e) {
            d_pm.getBean().resetNodeSplitModels();
            if (d_mainWindow instanceof AddisWindow) {
                d_mainWindow.reloadRightPanel(NODE_SPLIT_TAB_TITLE);
            }
        }
    });

    final JButton runAll = new JButton(MainWindow.IMAGELOADER.getIcon(org.drugis.mtc.gui.FileNames.ICON_RUN));
    runAll.setText("Run all node-split models");
    runAll.setToolTipText("Run all simulations");
    final List<Task> tasks = new ArrayList<Task>();
    for (final BasicParameter p : d_pm.getSplitParameters()) {
        final NodeSplitWrapper<TreatmentDefinition> wrapper = d_pm.getNodeSplitModel(p);
        if (!wrapper.isSaved()) {
            tasks.add(wrapper.getModel().getActivityTask());
        }
    }
    runAll.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            ThreadHandler.getInstance().scheduleTasks(tasks);
        }
    });

    panelBuilder.add(resetAll, cc.xy(3, 1));
    panelBuilder.add(runAll, cc.xy(1, 1));

    return panelBuilder.getPanel();
}

From source file:burp.BurpExtender.java

private JPanel createMainPanel() {
    JPanel main = new JPanel();
    main.setLayout(new GridBagLayout());

    // Create Settings Panel
    JPanel settings = new JPanel(new GridBagLayout());

    createTitle("Settings", settings);
    KeyListener projectEnter = new KeyAdapter() {
        @Override// w w w.  ja v  a 2s  .  c o  m
        public void keyPressed(KeyEvent k) {
            if (k.getKeyCode() == KeyEvent.VK_ENTER)
                updateProjects();
        }
    };

    serverUrl = labelTextField("Server URL: ", settings,
            callbacks.loadExtensionSetting(BurpExtender.SERVER_KEY));
    serverUrl.addKeyListener(projectEnter);
    serverUrl.addFocusListener(new JTextFieldSettingFocusListener(BurpExtender.SERVER_KEY, callbacks));

    apiKey = labelTextField("API Key: ", settings, callbacks.loadExtensionSetting(BurpExtender.API_KEY));
    apiKey.addKeyListener(projectEnter);
    apiKey.addFocusListener(new JTextFieldSettingFocusListener(BurpExtender.API_KEY, callbacks));

    JButton targetRefresh = new JButton();
    targetRefresh.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateTargets();
        }
    });
    targetUrl = createComboBox("Target URL: ", settings, 3, targetRefresh);

    projectRefresh = new JButton();
    projectRefresh.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Thread updateThread = new Thread() {
                public void run() {
                    NameValuePair selected = getProject();
                    if (selected != null)
                        callbacks.saveExtensionSetting(BurpExtender.PROJECT_KEY, selected.getValue());
                    updateProjects();
                }
            };
            updateThread.start();
        }
    });
    projectBox = createComboBox("Projects: ", settings, 4, projectRefresh);

    GridBagConstraints setGBC = new GridBagConstraints();
    setGBC.gridy = 3;
    setGBC.anchor = GridBagConstraints.NORTHWEST;
    main.add(settings, setGBC);

    // Separator
    Insets ins = new Insets(10, 10, 2, 10);

    JSeparator sep = new JSeparator(JSeparator.HORIZONTAL);
    callbacks.customizeUiComponent(sep);
    GridBagConstraints sepGBC = new GridBagConstraints();
    sepGBC.gridwidth = 3;
    sepGBC.gridx = 0;
    sepGBC.fill = GridBagConstraints.HORIZONTAL;
    sepGBC.insets = ins;
    main.add(sep, sepGBC);

    // Create Export Button
    JButton exportBtn = new JButton();
    exportBtn.setText("Send to Code Dx");
    exportBtn.addActionListener(new ExportActionListener(this, callbacks));
    callbacks.customizeUiComponent(exportBtn);
    GridBagConstraints btnGBC = new GridBagConstraints();
    btnGBC.gridx = 0;
    btnGBC.weightx = 1.0;
    btnGBC.weighty = 1.0;
    btnGBC.insets = ins;
    btnGBC.anchor = GridBagConstraints.NORTHWEST;
    main.add(exportBtn, btnGBC);

    updateTargets();
    return main;
}

From source file:com.raceup.fsae.test.TesterGui.java

/**
 * Monitor panel with Submit, Pause, Stop buttons
 *
 * @return panel to manage test//from   ww w.j a v a  2  s.  co  m
 */
private JPanel createMonitorPanel() {
    JPanel panel = new JPanel(); // monitor panel
    JButton submitButton = new JButton("Submit"); // create buttons
    JButton pauseButton = new JButton("Pause");
    JButton exitButton = new JButton("Exit");

    submitButton.addActionListener(e -> submitTest()); // add listeners
    pauseButton.addActionListener(e -> {
        pauseTest();

        if (isPaused) {
            pauseButton.setText("Resume");
        } else {
            pauseButton.setText("Pause");
        }
    });
    exitButton.addActionListener(e -> exitTest());

    panel.add(submitButton);
    panel.add(pauseButton);
    panel.add(exitButton);
    return panel;
}

From source file:cl.almejo.vsim.gui.SimWindow.java

private JButton newToolbarButton(Action action) {
    JButton button = new JButton();
    button.setAction(action);/*from  www  . j av a 2  s.c o  m*/
    button.setText("");
    return button;
}

From source file:io.github.jeremgamer.editor.panels.MusicFrame.java

public MusicFrame(JFrame frame, final GeneralSave gs) {

    ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>();
    try {/*from   w  w  w . ja v a2 s  .  c o m*/
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png")));
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    this.setIconImages((List<? extends Image>) icons);

    this.setTitle("Musique");
    this.setSize(new Dimension(300, 225));

    this.addWindowListener(new WindowListener() {
        @Override
        public void windowActivated(WindowEvent event) {
        }

        @Override
        public void windowClosed(WindowEvent event) {
        }

        @Override
        public void windowClosing(WindowEvent event) {
            try {
                gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd"));
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (clip != null) {
                clip.stop();
                clip.close();
                try {
                    audioStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        @Override
        public void windowDeactivated(WindowEvent event) {
        }

        @Override
        public void windowDeiconified(WindowEvent event) {
        }

        @Override
        public void windowIconified(WindowEvent event) {
        }

        @Override
        public void windowOpened(WindowEvent event) {
        }
    });

    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS));

    this.setModal(true);
    this.setLocationRelativeTo(frame);

    JPanel properties = new JPanel();
    properties.setBorder(BorderFactory.createTitledBorder("Lecture"));
    ButtonGroup bg = new ButtonGroup();
    bg.add(one);
    bg.add(loop);
    one.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent event) {
            JRadioButton rb = (JRadioButton) event.getSource();
            if (rb.isSelected()) {
                gs.set("music.reading", 0);
                try {
                    gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (clip != null) {
                    if (clip.isRunning())
                        clip.loop(0);
                }
            }
        }
    });
    loop.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent event) {
            JRadioButton rb = (JRadioButton) event.getSource();
            if (rb.isSelected()) {
                gs.set("music.reading", 1);
                try {
                    gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (clip != null) {
                    if (clip.isRunning())
                        clip.loop(Clip.LOOP_CONTINUOUSLY);
                }
            }
        }
    });
    properties.add(one);
    properties.add(loop);
    if (gs.getInt("music.reading") == 0) {
        one.setSelected(true);
    } else {
        loop.setSelected(true);
    }

    volume.setMaximum(100);
    volume.setMinimum(0);
    volume.setValue(30);
    volume.setPaintTicks(true);
    volume.setPaintLabels(true);
    volume.setMinorTickSpacing(10);
    volume.setMajorTickSpacing(20);
    volume.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent event) {
            JSlider slider = (JSlider) event.getSource();
            double value = slider.getValue();
            gain = value / 100;
            dB = (float) (Math.log(gain) / Math.log(10.0) * 20.0);
            if (clip != null)
                gainControl.setValue(dB);
            gs.set("music.volume", (int) value);
        }
    });
    volume.setValue(gs.getInt("music.volume"));
    properties.add(volume);
    properties.setPreferredSize(new Dimension(300, 125));

    content.add(properties);

    JPanel browsePanel = new JPanel();
    browsePanel.setBorder(BorderFactory.createTitledBorder(""));
    JButton browse = new JButton("Parcourir...");
    if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) {
        preview.setEnabled(false);
        browse.setText("");
        try {
            browse.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    browse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            JButton button = (JButton) event.getSource();
            if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) {
                if (clip != null) {
                    clip.stop();
                    clip.close();
                    try {
                        audioStream.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                name.setText("");
                preview.setEnabled(false);
                button.setText("Parcourir...");
                button.setIcon(null);
                new File("projects/" + Editor.getProjectName() + "/music.wav").delete();
                gs.set("music.name", "");
            } else {
                String path = null;
                JFileChooser chooser = new JFileChooser(Editor.lastPath);
                FileNameExtensionFilter filter = new FileNameExtensionFilter("Audio (WAV)", "wav");
                chooser.setFileFilter(filter);
                chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
                int option = chooser.showOpenDialog(null);
                if (option == JFileChooser.APPROVE_OPTION) {
                    path = chooser.getSelectedFile().getAbsolutePath();
                    Editor.lastPath = chooser.getSelectedFile().getParent();
                    copyMusic(new File(path));
                    button.setText("");
                    try {
                        button.setIcon(
                                new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    gs.set("music.name", new File(path).getName());
                    try {
                        gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd"));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    name.setText(new File(path).getName());
                    preview.setEnabled(true);
                }
            }
        }

    });
    if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) {
        preview.setEnabled(true);
    } else {
        preview.setEnabled(false);
    }
    preview.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            JToggleButton tb = (JToggleButton) event.getSource();
            if (tb.isSelected()) {
                try {
                    audioStream = AudioSystem.getAudioInputStream(
                            new File("projects/" + Editor.getProjectName() + "/music.wav"));
                    format = audioStream.getFormat();
                    info = new DataLine.Info(Clip.class, format);
                    clip = (Clip) AudioSystem.getLine(info);
                    clip.open(audioStream);
                    clip.start();
                    gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
                    gainControl.setValue(dB);
                    if (loop.isSelected()) {
                        clip.loop(Clip.LOOP_CONTINUOUSLY);
                    } else {
                        clip.loop(0);
                    }
                    clip.addLineListener(new LineListener() {
                        @Override
                        public void update(LineEvent event) {
                            Clip clip = (Clip) event.getSource();
                            if (!clip.isRunning()) {
                                preview.setSelected(false);
                                clip.stop();
                                clip.close();
                                try {
                                    audioStream.close();
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }
                            }
                        }

                    });
                } catch (Exception exc) {
                    exc.printStackTrace();
                }
            } else {
                clip.stop();
                clip.close();
                try {
                    audioStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    });
    JPanel buttons = new JPanel();
    buttons.setLayout(new BorderLayout());
    buttons.add(browse, BorderLayout.WEST);
    buttons.add(preview, BorderLayout.EAST);
    browsePanel.setLayout(new BorderLayout());
    browsePanel.add(buttons, BorderLayout.NORTH);
    browsePanel.add(name, BorderLayout.SOUTH);

    name.setPreferredSize(new Dimension(280, 25));
    name.setText(gs.getString("music.name"));
    content.add(browsePanel);

    this.setContentPane(content);
    this.setVisible(true);
}

From source file:com.willwinder.universalgcodesender.uielements.macros.MacroActionPanel.java

@Override
public void doLayout() {
    Settings s = backend.getSettings();/*from  www. j a v a  2s  . com*/

    // Lookup macros.
    if (macrosDirty) {
        Integer lastMacroIndex = s.getLastMacroIndex() + 1;
        macros.clear();
        for (int i = 0; i < lastMacroIndex; i++) {
            Macro m = s.getMacro(i);
            if (StringUtils.isNotEmpty(m.getGcode())) {
                macros.add(s.getMacro(i));
            }
        }
    }

    // Cache the largest width amongst the buttons.
    int maxWidth = 0;
    int maxHeight = 0;

    // Create buttons.
    for (int i = 0; i < macros.size(); i++) {
        final int index = i;
        Macro macro = macros.get(i);
        JButton button;
        if (customGcodeButtons.size() <= i) {
            button = new JButton(i + "");
            button.setEnabled(false);
            customGcodeButtons.add(button);
            // Add action listener
            button.addActionListener((ActionEvent evt) -> {
                customGcodeButtonActionPerformed(index);
            });
        } else {
            button = customGcodeButtons.get(i);
        }

        if (!StringUtils.isEmpty(macro.getName())) {
            button.setText(macro.getName());
        } else if (!StringUtils.isEmpty(macro.getDescription())) {
            button.setText(macro.getDescription());
        }

        if (!StringUtils.isEmpty(macro.getDescription())) {
            button.setToolTipText(macro.getDescription());
        }

        if (button.getPreferredSize().width > maxWidth)
            maxWidth = button.getPreferredSize().width;
        if (button.getPreferredSize().height > maxHeight)
            maxHeight = button.getPreferredSize().height;
    }

    // If button count was reduced, clear out any extras.
    if (customGcodeButtons.size() > macros.size()) {
        this.macroPanel.removeAll();
        this.macroPanel.repaint();
        for (int i = customGcodeButtons.size(); i > macros.size(); i--) {
            JButton b = customGcodeButtons.remove(i - 1);
        }
    }

    // Calculate columns/rows which can fit in the space we have.
    int columns = (getWidth() - (2 * INSET)) / (maxWidth + PADDING);
    int rows = (getHeight() - (2 * INSET)) / (maxHeight + PADDING);

    // At least one column.
    columns = Math.max(columns, 1);

    // Update number of rows if more are needed.
    if (columns * rows < customGcodeButtons.size()) {
        rows = customGcodeButtons.size() / columns;
        if (customGcodeButtons.size() % columns != 0)
            rows++;
    }

    // Layout for buttons.
    StringBuilder columnConstraint = new StringBuilder();
    for (int i = 0; i < columns; i++) {
        if (i > 0) {
            columnConstraint.append("unrelated");
        }
        columnConstraint.append("[fill, sg 1]");
    }
    MigLayout layout = new MigLayout("fillx, wrap " + columns + ", inset " + INSET,
            columnConstraint.toString());
    macroPanel.setLayout(layout);

    // Put buttons in grid.
    int x = 0;
    int y = 0;
    for (JButton button : customGcodeButtons) {
        macroPanel.add(button, "cell " + x + " " + y);
        y++;
        if (y == rows) {
            x++;
            y = 0;
        }
    }

    super.doLayout();
}

From source file:fungus.JungVisualizer.java

public JungVisualizer(String name) {
    this.name = name;

    showEdges = Configuration.getBoolean(name + "." + PAR_SHOW_EDGES);
    scaleShapes = Configuration.getBoolean(name + "." + PAR_SCALE_SHAPES);
    labelNodes = Configuration.getBoolean(name + "." + PAR_LABEL_NODES);
    imageDir = Configuration.getString(name + "." + PAR_IMAGE_DIR);
    nameFragment = Configuration.getString(PAR_TESTNAME);

    if (vt == null) {
        try {//from   w ww .j a v a2  s. c o m
            Class vtClass = Configuration.getClass(name + "." + PAR_TRANSFORMERS);
            if (VisualizerTransformers.class.isAssignableFrom(vtClass)) {
                vt = (VisualizerTransformers) vtClass.newInstance();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    graph = JungGraphObserver.getGraph();

    vt.setGraph(graph); // Have to call this manually!

    JungGraphObserver.stepBlocked = true;
    JungGraphObserver.noBlock = false;

    layout = vt.makeLayout(graph);

    Dimension preferredSize = new Dimension(660, 660);
    visualizationModel = new DefaultVisualizationModel<MycoNode, MycoEdge>(layout, preferredSize);

    relaxer = visualizationModel.getRelaxer();

    visualizer = new VisualizationViewer<MycoNode, MycoEdge>(visualizationModel, preferredSize);
    visualizer.addGraphMouseListener(new InfoFrameVertexListener());

    visualizer.setDoubleBuffered(true);

    // final Color under50VertexColor = Color.BLACK;
    // final Stroke under50VertexStroke = new BasicStroke(1.0f,
    //                                                    BasicStroke.CAP_BUTT,
    //                                                    BasicStroke.JOIN_MITER);
    // final Color over50VertexColor = Color.MAGENTA;
    // final Stroke over50VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over80VertexColor = Color.BLUE;
    // final Stroke over80VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over95VertexColor = Color.GREEN;
    // final Stroke over95VertexStroke = new BasicStroke(2.0f,
    //                                                   BasicStroke.CAP_BUTT,
    //                                                   BasicStroke.JOIN_MITER);
    // final Color over100VertexColor = Color.RED;
    // final Stroke over100VertexStroke = new BasicStroke(5.0f,
    //                                                    BasicStroke.CAP_BUTT,
    //                                                    BasicStroke.JOIN_MITER);
    // Transformer<MycoNode,Stroke> nodeStrokeRenderer =
    //     new Transformer<MycoNode, Stroke>() {
    //   public Stroke transform(MycoNode n){
    //     int capacity = n.getHyphaData().getMax();
    //     int attached = n.getHyphaLink().degree();
    //     double ratio = ((double) attached) / ((double) capacity);

    //     if (ratio > 1.0) {
    //       return over100VertexStroke;
    //     } else if (ratio > 0.95) {
    //       return over95VertexStroke;
    //     } else if (ratio > 0.80) {
    //       return over80VertexStroke;
    //     } else if (ratio > 0.50) {
    //       return over50VertexStroke;
    //     } else {
    //       return under50VertexStroke;
    //     }
    //   }
    // };
    // Transformer<MycoNode,Paint> nodeOutlineRenderer =
    //     new Transformer<MycoNode, Paint>() {
    //   public Paint transform(MycoNode n) {
    //     int capacity = n.getHyphaData().getMax();
    //     int attached = n.getHyphaLink().degree();
    //     double ratio = ((double) attached) / ((double) capacity);

    //     if (ratio > 1.0) {
    //       return over100VertexColor;
    //     } else if (ratio > 0.95) {
    //       return over95VertexColor;
    //     } else if (ratio > 0.80) {
    //       return over80VertexColor;
    //     } else if (ratio > 0.50) {
    //       return over50VertexColor;
    //     } else {
    //       return under50VertexColor;
    //     }
    //   }
    // };

    /*Transformer<MycoNode,Paint> nodeFillRenderer = new Transformer<MycoNode,Paint>() {
      public Paint transform(MycoNode n) {
      HyphaData data = n.getHyphaData();
      if (!n.isUp()) { return Color.BLACK; }
      if (data.isBiomass()) { return Color.BLUE; }
      else if (data.isExtending()) { return Color.RED; }
      else if (data.isBranching()) { return Color.YELLOW; }
      else { return Color.GREEN; }
      }
      };*/

    /*Transformer<MycoNode,Paint> nodeFillRenderer = new Transformer<MycoNode,Paint>() {
      public Paint transform(MycoNode n) {
      HyphaData data = n.getHyphaData();
      if (data.isBiomass()) { return Color.BLUE; }
      else if (data.isExtending()) { return Color.RED; }
      else if (data.isBranching()) { return Color.YELLOW; }
      else { return Color.GREEN; }
      }
      };*/

    final Color transparent = new Color(0, 0, 0, 0);

    Transformer<MycoEdge, Paint> transparentEdges = new Transformer<MycoEdge, Paint>() {
        public Paint transform(MycoEdge e) {
            return transparent;
        }
    };

    visualizer.setBackground(Color.WHITE);

    visualizer.getRenderContext().setVertexFillPaintTransformer(vt.getNodeFillRenderer());
    visualizer.getRenderContext().setVertexShapeTransformer(vt.getShapeTransformer(scaleShapes));
    if (labelNodes) {
        visualizer.getRenderContext().setVertexLabelTransformer(vt.getNodeLabeller());
    }
    visualizer.getRenderContext().setVertexStrokeTransformer(vt.getVertexStrokeTransformer());
    visualizer.getRenderContext().setVertexDrawPaintTransformer(vt.getVertexDrawPaintTransformer());
    //visualizer.setVertexToolTipTransformer(new ToStringLabeller());

    if (showEdges) {
        visualizer.getRenderContext().setEdgeStrokeTransformer(vt.getEdgeStrokeTransformer());
        visualizer.getRenderContext().setEdgeDrawPaintTransformer(vt.getEdgeDrawPaintTransformer());
        visualizer.getRenderContext().setArrowDrawPaintTransformer(vt.getEdgeDrawPaintTransformer());
        visualizer.getRenderContext().setArrowFillPaintTransformer(vt.getEdgeDrawPaintTransformer());
    } else {
        visualizer.getRenderContext().setEdgeDrawPaintTransformer(transparentEdges);
        visualizer.getRenderContext().setArrowDrawPaintTransformer(transparentEdges);
        visualizer.getRenderContext().setArrowFillPaintTransformer(transparentEdges);
    }

    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container c = frame.getContentPane();
    c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));

    //JScrollPane scrollPane = new JScrollPane(visualizer);
    //c.add(scrollPane);
    c.add(visualizer);

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));

    final JButton captureButton = new JButton("capture");
    ActionListener capturer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            saveAsPNG();
        }
    };
    captureButton.addActionListener(capturer);

    final JButton freezeButton = new JButton("freeze");
    ActionListener freezer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (freezeButton.getText().equals("freeze")) {
                relaxer.pause();
                freezeButton.setText("unfreeze");
            } else {
                relaxer.resume();
                freezeButton.setText("freeze");
            }
        }
    };
    freezeButton.addActionListener(freezer);

    JButton pauseButton = new JButton("pause");
    ActionListener pauser = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //e.consume();
            JungGraphObserver.pauseAction();
        }
    };
    pauseButton.addActionListener(pauser);

    JButton stepButton = new JButton("step");
    ActionListener stepper = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked!\n");
            //e.consume();
            JungGraphObserver.stepAction();
        }
    };
    stepButton.addActionListener(stepper);

    JButton walkButton = new JButton("walk");
    ActionListener walker = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked!\n");
            //e.consume();
            JungGraphObserver.walkAction();
        }
    };
    walkButton.addActionListener(walker);

    JButton runButton = new JButton("run");
    ActionListener runner = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //e.consume();
            JungGraphObserver.runAction();
        }
    };
    runButton.addActionListener(runner);

    roundField = new JTextField("0");

    buttonPane.add(freezeButton);
    buttonPane.add(captureButton);
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(pauseButton);
    buttonPane.add(stepButton);
    buttonPane.add(walkButton);
    buttonPane.add(runButton);
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(roundField);
    c.add(buttonPane);

    frame.pack();
    frame.setVisible(true);

    JungGraphObserver.setVisualizer(visualizer);
}