Example usage for javax.swing JOptionPane PLAIN_MESSAGE

List of usage examples for javax.swing JOptionPane PLAIN_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane PLAIN_MESSAGE.

Prototype

int PLAIN_MESSAGE

To view the source code for javax.swing JOptionPane PLAIN_MESSAGE.

Click Source Link

Document

No icon is used.

Usage

From source file:org.docx4all.swing.ExternalHyperlinkDialog.java

public ExternalHyperlinkDialog(WordMLEditor wmlEditor, String sourceFileVFSUrlPath, HyperlinkML hyperlinkML,
        FileNameExtensionFilter fileFilter) {
    super(wmlEditor.getWindowFrame(), true);

    this.sourceFileVFSUrlPath = sourceFileVFSUrlPath;
    this.hyperlinkML = hyperlinkML;
    this.fileFilter = fileFilter;
    this.value = CANCEL_BUTTON_TEXT;
    setTitle("External Hyperlink Setup");

    Object[] options = { OK_BUTTON_TEXT, CANCEL_BUTTON_TEXT };
    Object[] array = { createContentPanel(sourceFileVFSUrlPath, hyperlinkML) };
    this.optionPane = new JOptionPane(array, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_OPTION, null, options,
            options[0]);//w  w w  .ja v a2s.  c  o  m

    //Make this dialog display it.
    setContentPane(this.optionPane);

    //Handle window closing correctly.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            /*
             * Instead of directly closing the window, we're going to change
             * the JOptionPane's value property.
             */
            ExternalHyperlinkDialog.this.optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION));
        }
    });

    //Register an event handler that reacts to option pane state changes.
    this.optionPane.addPropertyChangeListener(this);
}

From source file:org.genedb.jogra.plugins.TermRationaliser.java

/**
 * Return a new JFrame which is the main interface to the Rationaliser.
 *//*from   w w  w  .  ja  v a 2 s. co m*/
public JFrame getMainPanel() {

    /* JFRAME */
    frame.setTitle(WINDOW_TITLE);
    frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    frame.setLayout(new BorderLayout());

    /* MENU */
    JMenuBar menuBar = new JMenuBar();

    JMenu actions_menu = new JMenu("Actions");
    JMenuItem actions_mitem_1 = new JMenuItem("Refresh lists");
    actions_mitem_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            initModels();
        }
    });
    actions_menu.add(actions_mitem_1);

    JMenu about_menu = new JMenu("About");
    JMenuItem about_mitem_1 = new JMenuItem("About");
    about_mitem_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JOptionPane.showMessageDialog(null,
                    "Term Rationaliser \n" + "Wellcome Trust Sanger Institute, UK \n" + "2009",
                    "Term Rationaliser", JOptionPane.PLAIN_MESSAGE);
        }
    });
    about_menu.add(about_mitem_1);

    menuBar.add(about_menu);
    menuBar.add(actions_menu);
    frame.add(menuBar, BorderLayout.NORTH);

    /* MAIN BOX */
    Box center = Box.createHorizontalBox(); //A box that displays contents from left to right
    center.add(Box.createHorizontalStrut(5)); //Invisible fixed-width component

    /* FROM LIST AND PANEL */
    fromList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); //Allow multiple products to be selected 
    fromList.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) {
                synchroniseLists(fromList, toList); //synchronise from left to right
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }

        @Override
        public void keyTyped(KeyEvent arg0) {
        }
    });

    Box fromPanel = this.createRationaliserPanel(FROM_LIST_NAME, fromList); //Box on left hand side
    fromPanel.add(Box.createVerticalStrut(55)); //Add some space
    center.add(fromPanel); //Add to main box
    center.add(Box.createHorizontalStrut(3)); //Add some space

    /* MIDDLE PANE */
    Box middlePane = Box.createVerticalBox();

    ClassLoader classLoader = this.getClass().getClassLoader(); //Needed to access the images later on
    ImageIcon leftButtonIcon = new ImageIcon(classLoader.getResource("left_arrow.gif"));
    ImageIcon rightButtonIcon = new ImageIcon(classLoader.getResource("right_arrow.gif"));

    leftButtonIcon = new ImageIcon(leftButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon!
    rightButtonIcon = new ImageIcon(rightButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon!

    JButton rightSynch = new JButton(rightButtonIcon);
    rightSynch.setToolTipText("Synchronise TO list. \n Shortcut: Right-arrow key");

    rightSynch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            synchroniseLists(fromList, toList);
        }
    });

    JButton leftSynch = new JButton(leftButtonIcon);
    leftSynch.setToolTipText("Synchronise FROM list. \n Shortcut: Left-arrow key");

    leftSynch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            synchroniseLists(toList, fromList);
        }
    });

    middlePane.add(rightSynch);
    middlePane.add(leftSynch);

    center.add(middlePane); //Add middle pane to main box
    center.add(Box.createHorizontalStrut(3));

    /* TO LIST AND PANEL */
    toList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //Single product selection in TO list
    toList.addKeyListener(new KeyListener() {
        @Override
        public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_LEFT) {
                synchroniseLists(toList, fromList); //synchronise from right to left
            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
        }

        @Override
        public void keyTyped(KeyEvent arg0) {
        }
    });

    Box toPanel = this.createRationaliserPanel(TO_LIST_NAME, toList);

    Box newTerm = Box.createVerticalBox();

    textField = new JTextArea(1, 1); //textfield to let the user edit the name of an existing term
    textField.setMaximumSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().height, 10));

    textField.setForeground(Color.BLUE);
    JScrollPane jsp = new JScrollPane(textField); //scroll pane so that there is a horizontal scrollbar
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    newTerm.add(jsp);
    TitledBorder editBorder = BorderFactory.createTitledBorder("Edit term name");
    editBorder.setTitleColor(Color.DARK_GRAY);
    newTerm.setBorder(editBorder);
    toPanel.add(newTerm); //add textfield to panel

    center.add(toPanel); //add panel to main box
    center.add(Box.createHorizontalStrut(5));

    frame.add(center); //add the main panel to the frame

    initModels(); //load the lists with data

    /* BOTTOM HALF OF FRAME */
    Box main = Box.createVerticalBox();
    TitledBorder border = BorderFactory.createTitledBorder("Information");
    border.setTitleColor(Color.DARK_GRAY);

    /* INFORMATION BOX */
    Box info = Box.createVerticalBox();

    Box scope = Box.createHorizontalBox();
    scope.add(Box.createHorizontalStrut(5));
    scope.add(scopeLabel); //label showing the scope of the terms
    scope.add(Box.createHorizontalGlue());

    Box productCount = Box.createHorizontalBox();
    productCount.add(Box.createHorizontalStrut(5));
    productCount.add(productCountLabel); //display the label showing the number of terms
    productCount.add(Box.createHorizontalGlue());

    info.add(scope);
    info.add(productCount);
    info.setBorder(border);

    /* ACTION BUTTONS */
    Box actionButtons = Box.createHorizontalBox();
    actionButtons.add(Box.createHorizontalGlue());
    actionButtons.add(Box.createHorizontalStrut(10));

    JButton findFix = new JButton(new FindClosestMatchAction());
    actionButtons.add(findFix);
    actionButtons.add(Box.createHorizontalStrut(10));

    RationaliserAction ra = new RationaliserAction();
    // RationaliserAction2 ra2 = new RationaliserAction2();
    JButton go = new JButton(ra);
    actionButtons.add(go);
    actionButtons.add(Box.createHorizontalGlue());

    /* MORE INFORMATION TOGGLE */
    Box buttonBox = Box.createHorizontalBox();
    final JButton toggle = new JButton("Hide information <<");

    buttonBox.add(Box.createHorizontalStrut(5));
    buttonBox.add(toggle);
    buttonBox.add(Box.createHorizontalGlue());

    Box textBox = Box.createHorizontalBox();

    final JScrollPane scrollPane = new JScrollPane(information);
    scrollPane.setPreferredSize(new Dimension(frame.getWidth(), 100));
    scrollPane.setVisible(true);
    textBox.add(Box.createHorizontalStrut(5));
    textBox.add(scrollPane);

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            if (toggle.getText().equals("Show information >>")) {
                scrollPane.setVisible(true);
                toggle.setText("Hide information <<");
                frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() + 100));
                frame.pack();
            } else if (toggle.getText().equals("Hide information <<")) {
                scrollPane.setVisible(false);
                toggle.setText("Show information >>");
                frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() - 100));
                frame.pack();
            }
        }
    };
    toggle.addActionListener(actionListener);

    main.add(Box.createVerticalStrut(5));
    main.add(info);
    main.add(Box.createVerticalStrut(5));
    main.add(Box.createVerticalStrut(5));
    main.add(actionButtons);
    main.add(Box.createVerticalStrut(10));
    main.add(buttonBox);
    main.add(textBox);

    frame.add(main, BorderLayout.SOUTH);
    frame.pack();
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setVisible(true);
    //initModels();

    return frame;
}

From source file:org.geworkbench.engine.ccm.CCMTableModel.java

/**
 * (non-Javadoc)//w  ww .  j a  v a2  s .  c o  m
 * 
 * @see javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object,
 *      int, int, boolean)
 */
final boolean selectRow(Object value, int modelRow, boolean validation) {
    PluginComponent record = rows.get(modelRow);

    selected.put(record, (Boolean) value);

    Boolean currentChoice = (Boolean) getModelValueAt(modelRow, CCMTableModel.SELECTION_INDEX);

    List<String> required = record.getRequired();
    List<String> related = record.getRelated();
    String folder = resourceFolders.get(record);
    File file = files.get(record);

    List<String> unselectedRequired = new ArrayList<String>();
    for (int i = 0; i < required.size(); i++) {
        String requiredClazz = required.get(i);
        Integer requiredRow = getModelRowByClazz(requiredClazz);
        Boolean requiredSelected = (Boolean) getModelValueAt(requiredRow.intValue(),
                CCMTableModel.SELECTION_INDEX);
        if (!requiredSelected) {
            unselectedRequired.add(requiredClazz);
        }
    }

    if (currentChoice.booleanValue()) {
        /* PLUGIN SELECTED */
        String propFileName = null;
        String cwbFileName = file.getName();
        if (cwbFileName.endsWith(".cwb.xml")) {
            propFileName = cwbFileName.replace(".cwb.xml", ".ccmproperties");
        } else {
            log.error(".cwb.xml file is expected. Actual file name " + cwbFileName);
        }
        String licenseAccepted = ComponentConfigurationManager.readProperty(folder, propFileName,
                "licenseAccepted");
        Boolean boolRequired = record.isMustAccept();
        boolean bRequired = boolRequired.booleanValue();
        if ((bRequired && (licenseAccepted == null))
                || (bRequired && licenseAccepted != null && !licenseAccepted.equalsIgnoreCase("true"))) {
            String componentName = (String) getModelValueAt(modelRow, CCMTableModel.NAME_INDEX);

            String title = "Terms Acceptance";
            String message = "\nBy clicking \"I Accept\", you signify that you \nhave read and accept the terms of the license \nagreement for the \""
                    + componentName
                    + "\" application.\n\nTo view this license, exit out of this dialog and click \non the View License button below.\n\n";
            Object[] options = { "I Accept", "No, thanks" };
            int choice = JOptionPane.showOptionDialog(null, message, title, JOptionPane.YES_NO_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null, options, options[0]);

            if (choice != 0) {
                ComponentConfigurationManager.writeProperty(folder, propFileName, "licenseAccepted", "false");
                selected.put(record, new Boolean(false));
                return false;
            }
            ComponentConfigurationManager.writeProperty(folder, propFileName, "licenseAccepted", "true");
        }

        if (!validation) {
            fireTableDataChanged();
            return true;
        }

        if (unselectedRequired.size() > 0 || related.size() > 0) {
            DependencyManager dmanager = new DependencyManager(this, unselectedRequired, modelRow, related);
            dmanager.checkDependency();
        }
    } else {
        /* PLUGIN UNSELECTED */
        List<Integer> dependentPlugins = null;

        String unselectedPluginClazz = "Plugin is missing a Class descriptor";
        int unselectedRow = modelRow;
        if (unselectedRow >= 0) {
            unselectedPluginClazz = (String) getModelValueAt(unselectedRow, CCMTableModel.CLASS_INDEX);
        }

        dependentPlugins = new ArrayList<Integer>();
        /*
         * Find Plugins that are dependent on this unselected plugin.
         */
        int rowCount = getModelRowCount();
        for (int i = 0; i < rowCount; i++) {

            /*
             * If the potentially dependent plugin is not selected,
             * don't bother to see if it is dependent
             */
            Boolean selected = (Boolean) getModelValueAt(i, CCMTableModel.SELECTION_INDEX);
            if (!selected.booleanValue()) {
                continue;
            }

            List<String> requiredList = rows.get(i).getRequired();

            for (int j = 0; j < requiredList.size(); j++) {
                String requiredClazz = requiredList.get(j);
                if (unselectedPluginClazz.equalsIgnoreCase(requiredClazz)) {
                    dependentPlugins.add(new Integer(i));
                    break;
                }
            }
        }

        if (!validation) {
            fireTableDataChanged();
            return true;
        }

        /* If dependencies are found, then popup a dialog */
        if (dependentPlugins.size() > 0) {
            DependencyManager dmanager = new DependencyManager(this, dependentPlugins, modelRow);
            dmanager.checkDependency();
        }
    }

    //      fireTableCellUpdated(modelRow, column);//FIXME no use

    return true;
}

From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java

private void findAvailableUpdatesFromTomcat() {

    installedRow = initialRow;//  w w w .  ja  v a  2  s  .c  o m
    //      String url = System.getProperty("remote_components_config_url");
    //remote_components_config_url=http://califano11.cgc.cpmc.columbia.edu:8080/componentRepository/deploycomponents.txt

    GlobalPreferences prefs = GlobalPreferences.getInstance();
    String url = prefs.getRCM_URL().trim();
    if (url == null || url == "") {
        log.info("No Remote Component Manager URL configured.");
        return;
    }
    url += "/deploycomponents.txt";

    HttpClient client = new HttpClient();
    client.getHttpConnectionManager().getParams().setConnectionTimeout(3000);
    GetMethod method = new GetMethod(url);
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
            new DefaultHttpMethodRetryHandler(3, false));
    method.setFollowRedirects(true);

    try {
        int statusCode = client.executeMethod(method);
        if (statusCode != HttpStatus.SC_OK) {
            JOptionPane.showMessageDialog(null,
                    "No updates are available at this time.\nPlease try again later.",
                    "Remote Component Update", JOptionPane.PLAIN_MESSAGE);
            return;
        }

        String deploycomponents = method.getResponseBodyAsString();
        //         String[] rows = deploycomponents.split("\\r\\n");
        String[] folderNameVersions = deploycomponents.split("\\r\\n");

        for (int i = 0; i < ccmTableModel.getModelRowCount(); i++) {
            String localFolderName = ccmTableModel.getResourceFolder(i);

            String localVersion = ((String) ccmTableModel.getModelValueAt(i, CCMTableModel2.VERSION_INDEX));
            Double dLocalVersion = new Double(localVersion);

            for (int j = 0; j < folderNameVersions.length; j++) {
                String[] cols = folderNameVersions[j].split(",");
                String remoteFolderName = cols[0];
                String remoteVersion = cols[1];
                Double dRemoteVersion = new Double(remoteVersion);

                if (localFolderName.equalsIgnoreCase(remoteFolderName)) {
                    if (dRemoteVersion.compareTo(dLocalVersion) > 0) {
                        ccmTableModel.setModelValueAt(remoteVersion, i, CCMTableModel2.AVAILABLE_UPDATE_INDEX,
                                CCMTableModel2.NO_VALIDATION);
                    }
                }
            }
        }
    } catch (HttpException e) {
        JOptionPane.showMessageDialog(null, "No updates are available at this time.\nPlease try again later.",
                "Remote Component Update", JOptionPane.PLAIN_MESSAGE);
        //e.printStackTrace();
        return;
    } catch (IOException e) {
        JOptionPane.showMessageDialog(null,
                e.getMessage() + ".\n(" + e.getClass().getName() + ")\nPlease try again later.",
                "No Update Available", JOptionPane.PLAIN_MESSAGE);
        //e.printStackTrace();
        return;
    } catch (Exception e) { // IllegalArgumentException
        JOptionPane.showMessageDialog(null, e.getMessage() + ".", "No Update Available",
                JOptionPane.PLAIN_MESSAGE);
    }
}

From source file:org.mathIT.gui.GraphViewer.java

/**
 * This method is called from within the constructor to initialize the frame.
 */// ww w .  j a v a  2s .  c o m
@SuppressWarnings({ "unchecked", "rawtypes" })
private void initComponents() {
    layout = new KKLayout<>(this.graph);
    //layout = new FRLayout<>(this.graph);
    //layout = new CircleLayout<>(this.graph);

    // Dimension preferredSize = new Dimension(840, 585); // old!
    Dimension preferredSize = new Dimension(900, 585);
    final VisualizationModel<V, E> visualizationModel = new DefaultVisualizationModel<>(layout, preferredSize);
    canvas = new GraphCanvas<>(this, visualizationModel, preferredSize);

    final PredicatedParallelEdgeIndexFunction<V, E> eif = PredicatedParallelEdgeIndexFunction.getInstance();
    final Set<E> exclusions = new HashSet<>();
    eif.setPredicate(new Predicate<E>() {
        @Override
        public boolean evaluate(E e) {
            return exclusions.contains(e);
        }
    });

    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(GraphViewer.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(GraphViewer.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(GraphViewer.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(GraphViewer.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    }

    canvas.setBackground(Color.white);

    // --- Vertex configuration: ---
    //canvas.getRenderContext().setVertexShapeTransformer(new GraphViewer.ClusterVertexShapeFunction());
    // ---- Vertex color: ----
    canvas.getRenderer()
            .setVertexRenderer(new edu.uci.ics.jung.visualization.renderers.GradientVertexRenderer<>(
                    Color.yellow, Color.yellow, // colors in normal state
                    Color.white, Color.red, // colors in picked state
                    canvas.getPickedVertexState(), false));
    //canvas.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<V>(canvas.getPickedVertexState(), Color.red, Color.yellow));

    pickActivated();

    // --- Vertex labels: -----
    canvas.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<>());
    canvas.getRenderer().getVertexLabelRenderer()
            .setPositioner(new BasicVertexLabelRenderer.InsidePositioner());
    canvas.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    // add a listener for ToolTips
    canvas.setVertexToolTipTransformer(new ToStringLabeller<V>() {
        /* (non-Javadoc)
         * @see edu.uci.ics.jung.visualization.decorators.DefaultToolTipFunction#getToolTipText(java.lang.Object)
         */
        @Override
        public String transform(V v) {
            if (v instanceof Graph) {
                return ((Graph<V>) v).getVertices().toString();
            }
            //return super.transform((V) v);
            return v.toString();
        }
    });

    // add a listener for ToolTips
    canvas.setEdgeToolTipTransformer(new ToStringLabeller<E>() {
        /* (non-Javadoc)
         * @see edu.uci.ics.jung.visualization.decorators.DefaultToolTipFunction#getToolTipText(java.lang.Object)
         */
        @Override
        public String transform(E e) {
            return e.toString();
        }
    });

    // ---  Edge Labels: ---
    canvas.getRenderContext().setParallelEdgeIndexFunction(eif);
    canvas.getRenderContext().getEdgeLabelRenderer();

    /**
     * the regular graph mouse for the normal view
     */
    final DefaultModalGraphMouse<V, E> graphMouse = new DefaultModalGraphMouse<>();

    canvas.setGraphMouse(graphMouse);

    // --- Control Panel: ---------------
    content = getContentPane();
    gzsp = new GraphZoomScrollPane(canvas);
    content.add(gzsp);

    modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    //graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Selection Mode"));
    modePanel.setLayout(new java.awt.GridLayout(3, 1));
    modePanel.add(modeBox);

    if (invokerGraph instanceof NetworkOfActivatables) {
        JButton next = new JButton("Next Activation Step");
        next.addActionListener((ActionEvent e) -> {
            nextActivationStep();
        });
        modePanel.add(next);
        JButton runAll = new JButton("Run Entire Activation");
        runAll.addActionListener((ActionEvent e) -> {
            runActivation();
        });
        modePanel.add(runAll);
    }

    scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener((ActionEvent e) -> {
        scaler.scale(canvas, 1.1f, canvas.getCenter());
    });
    JButton minus = new JButton("-");
    minus.addActionListener((ActionEvent e) -> {
        scaler.scale(canvas, 1 / 1.1f, canvas.getCenter());
    });

    buttonPanel = new JPanel();
    buttonPanel.setLayout(new java.awt.GridLayout(4, 1));
    print = new JButton("Print");
    print.addActionListener((ActionEvent e) -> {
        canvas.startPrinterJob();
    });
    buttonPanel.add(print);

    help = new JButton("Help");
    help.addActionListener((ActionEvent e) -> {
        JOptionPane.showMessageDialog((JComponent) e.getSource(), instructions, "Help",
                JOptionPane.PLAIN_MESSAGE);
    });
    buttonPanel.add(help);

    load = new JButton("Load CSV File");
    load.addActionListener((ActionEvent e) -> {
        //content.setCursor(new Cursor(Cursor.WAIT_CURSOR)); // funktioniert nicht...
        if (invokerGraph instanceof SocialNetwork) {
            SocialNetwork g = SocialNetwork.createNetworkFromCSVFile();
            if (g != null) {
                this.setVisible(false);
                //invokerGraph.shutDisplay();
                visualize(g);
            }
        } else if (invokerGraph instanceof WeightedGraph) {
            WeightedGraph<SimpleVertex> g = WeightedGraph.createWeightedGraphFromCSVFile();
            if (g != null) {
                this.setVisible(false);
                //invokerGraph.shutDisplay();
                visualize(g);
            }
        } else {
            org.mathIT.graphs.Graph<SimpleVertex> g = org.mathIT.graphs.Graph.createGraphFromCSVFile();
            if (g != null) {
                this.setVisible(false);
                //invokerGraph.shutDisplay();
                visualize(g);
            }
        }
        // content.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); // funktioniert nicht...
    });
    buttonPanel.add(load);

    save = new JButton("Save as CSV");
    save.addActionListener((ActionEvent e) -> {
        if (invokerGraph instanceof SocialNetwork) {
            for (V v : graph.getVertices()) {
                Activatable a = (Activatable) v;
                if (canvas.getPickedVertexState().isPicked(v)) {
                    ((NetworkOfActivatables<Activatable>) invokerGraph).setActive(true);
                    a.setActive(true);
                    //} else {
                    //   a.setActive(false);
                }
            }
            ((SocialNetwork) invokerGraph).saveAsCSV();
        } else if (invokerGraph instanceof WeightedGraph) {
            ((WeightedGraph<V>) invokerGraph).saveAsCSV();
        } else {
            invokerGraph.saveAsCSV();
        }
    });
    buttonPanel.add(save);

    Class<? extends Layout<?, ?>>[] combos = getCombos();
    jcb = new JComboBox<>(combos);
    // use a renderer to shorten the layout name presentation
    jcb.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            String valueString = value.toString();
            valueString = valueString.substring(valueString.lastIndexOf('.') + 1);
            return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus);
        }
    });
    jcb.addActionListener(new GraphViewer.LayoutChooser(jcb, canvas));
    //jcb.setSelectedItem(KKLayout.class);
    //jcb.setSelectedItem(FRLayout.class);
    //jcb.setSelectedItem(CircleLayout.class);
    jcb.setSelectedItem(layout.getClass());

    layoutChoice = new JPanel();
    layoutChoice.setBorder(BorderFactory.createTitledBorder("Graph Layout"));
    layoutChoice.setLayout(new java.awt.GridLayout(2, 1));
    layoutChoice.add(jcb);

    // Edge labels:
    edgePanel = new JPanel();
    edgeLabels = new javax.swing.JCheckBox("Edge Labels");
    edgePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING));
    edgeLabels.addActionListener((java.awt.event.ActionEvent evt) -> {
        writeEdgeLabels();
    });
    edgePanel.add(edgeLabels);
    edgePanel.add(edgeLabels);
    layoutChoice.add(edgePanel);

    clusterControls = new JPanel(new GridLayout(3, 1));
    if (invokerGraph instanceof org.mathIT.graphs.Graph) {
        clusterControls.setBorder(BorderFactory.createTitledBorder("Clusters"));
        JButton detect = new JButton("Detect (Greedy)");
        detect.addActionListener((ActionEvent e) -> {
            detectClusters();
        });
        clusterControls.add(detect);

        JButton detectExactly = new JButton("Detect (Brute force)");
        detectExactly.addActionListener((ActionEvent e) -> {
            detectClustersExactly();
        });
        clusterControls.add(detectExactly);

        JButton influencers = new JButton("Network Relevance");
        influencers.addActionListener((ActionEvent e) -> {
            displayRelevanceClusters();
        });
        clusterControls.add(influencers);
    }

    matrixControls = new JPanel(new GridLayout(3, 1));
    if (invokerGraph instanceof org.mathIT.graphs.Graph) {
        matrixControls.setBorder(BorderFactory.createTitledBorder("Matrices"));
        JButton adjacency = new JButton("Adjacency");
        adjacency.addActionListener((ActionEvent e) -> {
            org.mathIT.algebra.Matrix A = new org.mathIT.algebra.Matrix(invokerGraph.getAdjacency());
            new org.mathIT.gui.MatrixAlgebra("Adjacency matrix", A);
        });
        matrixControls.add(adjacency);

        JButton computeHashimoto = new JButton("Hashimoto");
        computeHashimoto.addActionListener((ActionEvent e) -> {
            org.mathIT.algebra.Matrix B = new org.mathIT.algebra.Matrix(invokerGraph.computeHashimoto());
            new org.mathIT.gui.MatrixAlgebra("Hashimoto matrix", B);
        });
        matrixControls.add(computeHashimoto);
    }

    // --- Build up Control Panel: ----
    controls = new JPanel();
    //controls.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER));
    zoomControls = new JPanel(new GridLayout(2, 1));
    zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom"));
    zoomControls.add(plus);
    zoomControls.add(minus);
    controls.add(zoomControls);
    controls.add(layoutChoice);
    controls.add(modePanel);
    if (invokerGraph instanceof org.mathIT.graphs.Graph) {
        controls.add(clusterControls);
        controls.add(matrixControls);
    }
    controls.add(buttonPanel);
    content.add(controls, BorderLayout.SOUTH);

    // Frame Properties:
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setLocationRelativeTo(null);
    //layout.setSize(canvas.getSize());
    //scaler.scale(canvas, 1.f, canvas.getCenter());
    setVisible(true);
}

From source file:org.monome.pages.AbletonClipSkipperPage.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("Add MIDI Output")) {
        String[] midiOutOptions = this.monome.getMidiOutOptions();
        String deviceName = (String) JOptionPane.showInputDialog(this.monome, "Choose a MIDI Output to add",
                "Add MIDI Output", JOptionPane.PLAIN_MESSAGE, null, midiOutOptions, "");

        if (deviceName == null) {
            return;
        }/*  ww w.  j  a  v a2 s  .com*/
        this.addMidiOutDevice(deviceName);
    }

    if (e.getActionCommand().equals("Refresh from Ableton")) {
        this.refreshAbleton();
    }
}

From source file:org.monome.pages.MachineDrumInterfacePage.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("Set MIDI Output")) {
        String[] midiOutOptions = this.monome.getMidiOutOptions();
        String deviceName = (String) JOptionPane.showInputDialog(this.monome, "Choose a MIDI Output to add",
                "Set MIDI Output", JOptionPane.PLAIN_MESSAGE, null, midiOutOptions, "");

        if (deviceName == null) {
            return;
        }//from   w  ww. ja v a2  s. co  m

        this.addMidiOutDevice(deviceName);
    }

    if (e.getActionCommand().equals("Update Preferences")) {
        this.speed = Integer.parseInt(this.getSpeedTF().getText());
    }
}

From source file:org.monome.pages.MIDIFadersPage.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("Add MIDI Output")) {
        String[] midiOutOptions = this.monome.getMidiOutOptions();
        String deviceName = (String) JOptionPane.showInputDialog(this.monome, "Choose a MIDI Output to add",
                "Add MIDI Output", JOptionPane.PLAIN_MESSAGE, null, midiOutOptions, "");

        if (deviceName == null) {
            return;
        }//from  w  w w . j  av a2 s. c o  m

        this.addMidiOutDevice(deviceName);
    }

    if (e.getActionCommand().equals("Update Preferences")) {
        this.delayAmount = Integer.parseInt(this.getDelayTF().getText());
        this.midiChannel = Integer.parseInt(this.getChannelTF().getText()) - 1;
        if (this.midiChannel < 0)
            this.midiChannel = 0;
        this.ccOffset = Integer.parseInt(this.getCcOffsetTF().getText());
    }
}

From source file:org.monome.pages.MIDIKeyboardJulienBPage.java

public void actionPerformed(ActionEvent e) {
    System.out.println(e.getActionCommand());
    if (e.getActionCommand().equals("Add MIDI Output")) {
        String[] midiOutOptions = this.monome.getMidiOutOptions();
        String deviceName = (String) JOptionPane.showInputDialog(this.monome, "Choose a MIDI Output to add",
                "Add MIDI Output", JOptionPane.PLAIN_MESSAGE, null, midiOutOptions, "");

        if (deviceName == null) {
            return;
        }/*from  ww w.  j av  a  2s. c  o  m*/

        this.addMidiOutDevice(deviceName);

    }
}

From source file:org.monome.pages.MIDIKeyboardPage.java

public void actionPerformed(ActionEvent e) {
    System.out.println(e.getActionCommand());
    if (e.getActionCommand().equals("Set MIDI Output")) {
        String[] midiOutOptions = this.monome.getMidiOutOptions();
        String deviceName = (String) JOptionPane.showInputDialog(this.monome, "Choose a MIDI Output to use",
                "Set MIDI Output", JOptionPane.PLAIN_MESSAGE, null, midiOutOptions, "");

        if (deviceName == null) {
            return;
        }/*from w w w. ja v a  2s  .c  o  m*/

        this.addMidiOutDevice(deviceName);

    }
    if (e.getActionCommand().equals("Update Preferences")) {
        String s[] = new String[6];
        s[0] = this.scaleTF1.getText();
        s[1] = this.scaleTF2.getText();
        s[2] = this.scaleTF3.getText();
        s[3] = this.scaleTF4.getText();
        s[4] = this.scaleTF5.getText();
        s[5] = this.scaleTF6.getText();
        setScales(s);
    }

    if (e.getActionCommand().equals("Reset Scales")) {
        this.scales = this.scalesDefault;
        this.getScales();
    }
}