Example usage for java.awt.event ActionEvent getSource

List of usage examples for java.awt.event ActionEvent getSource

Introduction

In this page you can find the example usage for java.awt.event ActionEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:ffx.ui.KeywordPanel.java

/**
 * Handles input from KeywordPanel ToolBar buttons.
 *
 * {@inheritDoc}//www  .  ja v a  2  s.c o m
 */
@Override
public void actionPerformed(ActionEvent evt) {
    String arg = evt.getActionCommand();
    switch (arg) {
    case "Open...":
        keyOpen();
        break;
    case "Close":
        keyClose();
        break;
    case "Save":
        keySave(currentKeyFile);
        break;
    case "Save As...":
        keySaveAs();
        break;
    case "Description":
        JCheckBoxMenuItem box = (JCheckBoxMenuItem) evt.getSource();
        setDivider(box.isSelected());
        break;
    }
    if (evt.getSource() instanceof JComboBox) {
        loadKeywordGroup();
    }
}

From source file:com.mirth.connect.client.ui.editors.filter.FilterPane.java

public void makeFilterTable() {
    filterTable = new MirthTable();

    filterTable.setModel(new DefaultTableModel(new String[] { "#", "Operator", "Name", "Type", "Data" }, 0) {

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            boolean[] canEdit;
            FilterRulePlugin plugin;//from   ww w .j  a v  a  2s .c  om
            try {
                plugin = getPlugin((String) filterTableModel.getValueAt(rowIndex, RULE_TYPE_COL));
                canEdit = new boolean[] { false, true, plugin.isNameEditable(), true, true };
            } catch (Exception e) {
                canEdit = new boolean[] { false, true, true, true, true };
            }
            return canEdit[columnIndex];
        }
    });

    filterTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    filterTableModel = (DefaultTableModel) filterTable.getModel();

    filterTable.getColumnModel().getColumn(RULE_NAME_COL).setCellEditor(new EditorTableCellEditor(this));
    filterTable.setCustomEditorControls(true);

    // Set the combobox editor on the operator column, and add action
    // listener
    MirthComboBoxTableCellEditor comboBoxOp = new MirthComboBoxTableCellEditor(filterTable, comboBoxValues, 2,
            true, new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    modified = true;
                    updateOperations();
                }
            });

    // Set the combobox editor on the type column, and add action listener
    String[] defaultComboBoxValues = new String[LoadedExtensions.getInstance().getFilterRulePlugins().size()];
    FilterRulePlugin[] pluginArray = LoadedExtensions.getInstance().getFilterRulePlugins().values()
            .toArray(new FilterRulePlugin[0]);
    for (int i = 0; i < pluginArray.length; i++) {
        defaultComboBoxValues[i] = pluginArray[i].getPluginPointName();
    }

    MirthComboBoxTableCellEditor comboBoxType = new MirthComboBoxTableCellEditor(filterTable,
            defaultComboBoxValues, 2, true, new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    if (filterTable.getEditingRow() != -1) {
                        int row = getSelectedRow();
                        String selectedType = ((JComboBox) evt.getSource()).getSelectedItem().toString();
                        String previousType = (String) filterTable.getValueAt(row, RULE_TYPE_COL);

                        if (selectedType.equalsIgnoreCase(previousType)) {
                            return;
                        }

                        modified = true;
                        FilterRulePlugin plugin;
                        try {
                            if (rulePanel.isModified() && !PlatformUI.MIRTH_FRAME.alertOption(
                                    PlatformUI.MIRTH_FRAME,
                                    "Are you sure you would like to change this filter rule and lose all of the current filter data?")) {
                                ((JComboBox) evt.getSource()).getModel().setSelectedItem(previousType);
                                return;
                            }

                            plugin = getPlugin(selectedType);
                            plugin.initData();
                            filterTableModel.setValueAt(plugin.getNewName(), row, RULE_NAME_COL);
                            rulePanel.showCard(selectedType);
                            updateTaskPane(selectedType);
                            updateCodePanel(selectedType);
                        } catch (Exception e) {
                            parent.alertThrowable(parent, e);
                        }

                    }
                }
            });

    filterTable.setSelectionMode(0); // only select one row at a time

    filterTable.getColumnExt(RULE_NUMBER_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    filterTable.getColumnExt(RULE_OP_COL).setMaxWidth(UIConstants.MAX_WIDTH);

    filterTable.getColumnExt(RULE_NUMBER_COL).setPreferredWidth(30);
    filterTable.getColumnExt(RULE_OP_COL).setPreferredWidth(60);

    filterTable.getColumnExt(RULE_NUMBER_COL).setCellRenderer(new CenterCellRenderer());
    filterTable.getColumnExt(RULE_OP_COL).setCellEditor(comboBoxOp);
    filterTable.getColumnExt(RULE_OP_COL).setCellRenderer(new MirthComboBoxTableCellRenderer(comboBoxValues) {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            if (value instanceof String && value.equals("")) {
                value = null;
            } else if (value != null) {
                value = value.toString();
            }

            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        }
    });

    filterTable.getColumnExt(RULE_TYPE_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    filterTable.getColumnExt(RULE_TYPE_COL).setMinWidth(120);
    filterTable.getColumnExt(RULE_TYPE_COL).setPreferredWidth(120);
    filterTable.getColumnExt(RULE_TYPE_COL).setCellEditor(comboBoxType);
    filterTable.getColumnExt(RULE_TYPE_COL)
            .setCellRenderer(new MirthComboBoxTableCellRenderer(defaultComboBoxValues));

    filterTable.getColumnExt(RULE_DATA_COL).setVisible(false);

    filterTable.setRowHeight(UIConstants.ROW_HEIGHT);
    filterTable.packTable(UIConstants.COL_MARGIN);
    filterTable.setSortable(false);
    filterTable.setOpaque(true);
    filterTable.setRowSelectionAllowed(true);
    filterTable.setDragEnabled(false);
    filterTable.getTableHeader().setReorderingAllowed(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        filterTable.setHighlighters(highlighter);
    }

    filterTable.setDropTarget(dropTarget);
    filterTablePane.setDropTarget(dropTarget);

    filterTable.setBorder(BorderFactory.createEmptyBorder());
    filterTablePane.setBorder(BorderFactory.createEmptyBorder());

    filterTablePane.setViewportView(filterTable);

    filterTable.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }

        public void mouseReleased(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }
    });

    filterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            if (!updating && !evt.getValueIsAdjusting()) {
                FilterListSelected(evt);
                updateCodePanel(null);
            }
        }
    });
    filterTable.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                deleteRule();
            }
        }

        public void keyReleased(KeyEvent e) {
        }

        public void keyTyped(KeyEvent e) {
        }
    });
}

From source file:org.apache.jmeter.visualizers.CreateReport.java

@Override
public void actionPerformed(ActionEvent ev) {
    /*//w  ww. j  a v  a 2  s  . co m
     if(ev.equals(SAVEASCSV))
      {
         saveAsCsv.setSelected(true);
      }
      else if (ev.equals(SAVEASPDF)
      {
         saveAsPdf.setSelected(true);
      }
     */

    String action = ev.getActionCommand();

    if (action.equals(BROWSE)) {

        JFileChooser j = new JFileChooser();
        j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int returnVal = j.showOpenDialog(this);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            basepath.setText(j.getSelectedFile().getAbsolutePath());
            BASEPATH = basepath.getText().trim();
            JOptionPane.showMessageDialog(null, "alert", basepath.getText(), JOptionPane.OK_OPTION);

        }
        if (ev.getSource() == saveTable) {
            JFileChooser chooser = FileDialoger.promptToSaveFile("summary.csv");//$NON-NLS-1$
            if (chooser == null) {
                return;
            }
            FileWriter writer = null;
            try {
                writer = new FileWriter(chooser.getSelectedFile());
                CSVSaveService.saveCSVStats(model, writer, saveHeaders.isSelected());
            } catch (FileNotFoundException e) {
                log.warn(e.getMessage());
            } catch (IOException e) {
                log.warn(e.getMessage());
            } finally {
                JOrphanUtils.closeQuietly(writer);
            }
        }
    }

}

From source file:homenetapp.HomeNetAppGui.java

private void enableServerCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enableServerCheckBoxActionPerformed
    javax.swing.JCheckBox checkbox = (javax.swing.JCheckBox) evt.getSource();
    if (checkbox.isSelected()) {
        enableUPnPCheckBox.setEnabled(true);
        serverPortLabel.setEnabled(true);
        serverPortTextField.setEnabled(true);
        System.out.println("Selected");
    } else {//from ww w  .j a v  a 2s.c  om
        enableUPnPCheckBox.setEnabled(false);
        serverPortLabel.setEnabled(false);
        serverPortTextField.setEnabled(false);
        System.out.println("Not Selected");
    }
}

From source file:homenetapp.HomeNetAppGui.java

private void autoUpdateToggleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoUpdateToggleButtonActionPerformed
    //if selected
    javax.swing.JToggleButton button = (javax.swing.JToggleButton) evt.getSource();
    if (button.isSelected()) {
        System.out.println("Button Toggled");
    } else {/*from  w  w  w  . j a  v  a  2 s  .c o m*/
        System.out.println("Button UnToggled");
    }
    //else
}

From source file:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java

public void makeTransformerTable() {
    transformerTable = new MirthTable();
    transformerTable.setBorder(BorderFactory.createEmptyBorder());

    // Data Column is hidden
    transformerTable.setModel(new DefaultTableModel(new String[] { "#", "Name", "Type", "Data" }, 0) {

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            boolean[] canEdit;
            TransformerStepPlugin plugin;
            try {
                plugin = getPlugin((String) transformerTableModel.getValueAt(rowIndex, STEP_TYPE_COL));
                canEdit = new boolean[] { false, plugin.isNameEditable(), true, true };
            } catch (Exception e) {
                canEdit = new boolean[] { false, false, true, true };
            }//from  w  ww .j  ava2 s  .  c o m
            return canEdit[columnIndex];
        }
    });

    transformerTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    transformerTableModel = (DefaultTableModel) transformerTable.getModel();

    transformerTable.getColumnModel().getColumn(STEP_NAME_COL).setCellEditor(new EditorTableCellEditor(this));
    transformerTable.setCustomEditorControls(true);

    // Set the combobox editor on the type column, and add action listener
    String[] defaultComboBoxValues = new String[LoadedExtensions.getInstance().getTransformerStepPlugins()
            .size()];
    TransformerStepPlugin[] pluginArray = LoadedExtensions.getInstance().getTransformerStepPlugins().values()
            .toArray(new TransformerStepPlugin[0]);
    for (int i = 0; i < pluginArray.length; i++) {
        defaultComboBoxValues[i] = pluginArray[i].getPluginPointName();
    }

    MirthComboBoxTableCellEditor comboBox = new MirthComboBoxTableCellEditor(transformerTable,
            defaultComboBoxValues, 2, true, new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    if (transformerTable.getEditingRow() != -1) {
                        int row = getSelectedRow();
                        String selectedType = ((JComboBox) evt.getSource()).getSelectedItem().toString();
                        String previousType = (String) transformerTable.getValueAt(row, STEP_TYPE_COL);

                        if (selectedType.equalsIgnoreCase(previousType)) {
                            return;
                        }

                        modified = true;
                        invalidVar = false;
                        TransformerStepPlugin plugin = null;
                        try {

                            if (stepPanel.isModified() && !PlatformUI.MIRTH_FRAME.alertOption(
                                    PlatformUI.MIRTH_FRAME,
                                    "Are you sure you would like to change this transformer step and lose all of the current transformer data?")) {
                                ((JComboBox) evt.getSource()).getModel().setSelectedItem(previousType);
                                return;
                            }

                            plugin = getPlugin(selectedType);
                            plugin.initData();
                            transformerTableModel.setValueAt(plugin.getNewName(), row, STEP_NAME_COL);
                            stepPanel.showCard(selectedType);
                            updateTaskPane(selectedType);
                            updateCodePanel(selectedType);
                        } catch (Exception e) {
                            parent.alertThrowable(PlatformUI.MIRTH_FRAME, e);
                        }
                    }
                }
            });

    transformerTable.setSelectionMode(0); // only select one row at a time

    transformerTable.getColumnExt(STEP_NUMBER_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    transformerTable.getColumnExt(STEP_TYPE_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    transformerTable.getColumnExt(STEP_TYPE_COL).setMinWidth(120);

    transformerTable.getColumnExt(STEP_NUMBER_COL).setPreferredWidth(30);
    transformerTable.getColumnExt(STEP_TYPE_COL).setPreferredWidth(120);

    transformerTable.getColumnExt(STEP_NUMBER_COL).setCellRenderer(new CenterCellRenderer());
    transformerTable.getColumnExt(STEP_TYPE_COL).setCellEditor(comboBox);
    transformerTable.getColumnExt(STEP_TYPE_COL)
            .setCellRenderer(new MirthComboBoxTableCellRenderer(defaultComboBoxValues));

    transformerTable.getColumnExt(STEP_DATA_COL).setVisible(false);

    transformerTable.setRowHeight(UIConstants.ROW_HEIGHT);
    transformerTable.packTable(UIConstants.COL_MARGIN);
    transformerTable.setSortable(false);
    transformerTable.setOpaque(true);
    transformerTable.setRowSelectionAllowed(true);
    transformerTable.setDragEnabled(false);
    transformerTable.getTableHeader().setReorderingAllowed(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        transformerTable.setHighlighters(highlighter);
    }

    transformerTable.setDropTarget(dropTarget);
    transformerTablePane.setDropTarget(dropTarget);

    transformerTable.setBorder(BorderFactory.createEmptyBorder());
    transformerTablePane.setBorder(BorderFactory.createEmptyBorder());
    transformerTablePane.setViewportView(transformerTable);

    // listen for mouse clicks on the actual table
    transformerTable.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }

        public void mouseReleased(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }
    });

    transformerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            if (!updating && !evt.getValueIsAdjusting()) {
                TransformerListSelected(evt);
                updateCodePanel(null);
            }
        }
    });
    transformerTable.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                deleteStep();
            }
        }

        public void keyReleased(KeyEvent e) {
        }

        public void keyTyped(KeyEvent e) {
        }
    });
}

From source file:ffx.ui.ModelingPanel.java

/**
 * This handles conditional command option input.
 *
 * @param evt ActionEvent//  w w w .  ja v  a 2s . c  o m
 */
private void conditionalCommandEvent(ActionEvent evt) {
    Object source = evt.getSource();
    if (source instanceof JRadioButton) {
        JRadioButton jrb = (JRadioButton) source;
        String selection = jrb.getText().toLowerCase();
        for (JLabel label : conditionals) {
            JTextField jtf = (JTextField) label.getLabelFor();
            String cupon = label.getName().toLowerCase();
            if (cupon.contains(selection) && jrb.isSelected()) {
                label.setEnabled(true);
                jtf.setEnabled(true);
            } else {
                label.setEnabled(false);
                jtf.setEnabled(false);
            }
        }
    } else if (source instanceof JCheckBox) {
        JCheckBox jcb = (JCheckBox) source;
        String selection = jcb.getText().toLowerCase();
        for (JLabel label : conditionals) {
            String cupon = label.getName().toLowerCase();
            JTextField jtf = (JTextField) label.getLabelFor();
            if (cupon.contains(selection) && jcb.isSelected()) {
                label.setEnabled(true);
                jtf.setEnabled(true);
            } else {
                label.setEnabled(false);
                jtf.setEnabled(false);
            }
        }
    }
    statusLabel.setText("  " + createCommandInput());
}

From source file:io.github.jeremgamer.editor.ManagerFrame.java

public ManagerFrame(String projectName, final JFrame parent) {
    dialog = this;

    ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>();
    try {//from  ww  w . ja v a2s .  c  om
        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("Grer les projets");
    this.setSize(300, 200);
    this.setModal(true);
    this.setLocationRelativeTo(parent);
    this.setResizable(false);

    final JScrollPane scroll = new JScrollPane(content);
    scroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    content.setBorder(BorderFactory.createTitledBorder(""));
    content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS));
    for (File project : new File("projects").listFiles()) {
        if (project.getName().equals(Editor.getProjectName())) {
            content.add(new ProjectPanel(project.getName(), true, parent, this));
        } else {
            content.add(new ProjectPanel(project.getName(), false, parent, this));
        }
    }
    try {
        final JButton add = new JButton("Crer un nouveau projet",
                new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png"))));
        newProjectPanel.add(newProjectName);
        newProjectPanel.add(validate);

        this.setLayout(new BorderLayout());
        scroll.setBorder(null);
        this.add(scroll, BorderLayout.CENTER);
        this.add(add, BorderLayout.SOUTH);

        add.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                validate.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        dispose();
                        parent.dispose();
                        new Thread(new Runnable() {
                            public void run() {
                                window.getContentPane()
                                        .add(new JLabel("",
                                                new ImageIcon(ImageGetter.class.getResource("splash.gif")),
                                                SwingConstants.CENTER));
                                window.setBackground(new Color(0, 0, 0, 0));
                                window.setSize(300, 300);
                                window.setLocationRelativeTo(null);
                                window.setVisible(true);
                            }
                        }).start();

                        new Thread(new Runnable() {
                            public void run() {
                                new Editor(newProjectName.getText());
                                window.setVisible(false);
                            }
                        }).start();
                    }
                });
                CaretListener caretUpdate = new CaretListener() {
                    public void caretUpdate(javax.swing.event.CaretEvent e) {
                        JTextField text = (JTextField) e.getSource();
                        for (File dir : new File("projects").listFiles()) {
                            if (dir.isDirectory() && text.getText().equals(dir.getName())) {
                                validate.setEnabled(false);
                                validate.setText("Existe dj");
                                break;
                            } else {
                                validate.setEnabled(true);
                                validate.setText("Crer!");
                            }
                        }
                    }
                };
                JButton cancel = null;
                try {
                    cancel = new JButton(
                            new ImageIcon(ImageIO.read(ImageGetter.class.getResource("cancel.png"))));
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
                newProjectName.addCaretListener(caretUpdate);
                remove(add);
                addPanel.setLayout(new BorderLayout());
                addPanel.add(newProjectPanel, BorderLayout.CENTER);
                addPanel.add(cancel, BorderLayout.EAST);
                add(addPanel, BorderLayout.SOUTH);
                revalidate();
                repaint();
                cancel.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent event) {
                        newProjectName.setText("");
                        remove(addPanel);
                        add(add, BorderLayout.SOUTH);
                        revalidate();
                        repaint();
                    }

                });
                newProjectName.requestFocusInWindow();
                newProjectName.requestFocus();
            }

        });
        this.setVisible(true);
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:ffx.ui.ModelingPanel.java

private void builderCommandEvent(ActionEvent evt) {
    JButton button = (JButton) evt.getSource();
    String arg = evt.getActionCommand();
    int index = acidComboBox.getSelectedIndex();
    String selected = (String) acidComboBox.getItemAt(index);
    if ("Remove".equals(button.getText())) {
        // Remove one entry
        if (acidComboBox.getItemCount() > 0) {
            acidComboBox.removeItemAt(index);
            index--;/*from w w  w.j a  v a  2  s . co m*/
        }
    } else if ("Edit".equals(button.getText())) {
        String entry = new String(acidTextField.getText());
        // Allow editing - should add more input validation here
        if (!entry.equals("")) {
            String s[] = entry.trim().split(" +");
            String newResidue = s[0].toUpperCase();
            if ("NUCLEIC".equals(arg)) {
                // Residue.NA3Set.contains(newResidue);
                try {
                    Residue.NA3.valueOf(newResidue);
                    acidComboBox.removeItemAt(index);
                    acidComboBox.insertItemAt("" + index + " " + entry, index);
                } catch (Exception e) {
                }
            } else {
                try {
                    Residue.AA3.valueOf(newResidue);
                    acidComboBox.removeItemAt(index);
                    acidComboBox.insertItemAt("" + index + " " + entry, index);
                } catch (Exception e) {
                }
            }
        }
    } else if ("Reset".equals(button.getText())) {
        // Remove all entries
        acidComboBox.removeAllItems();
        acidTextArea.setText("");
    } else {
        // A base/residue button was selected
        String newResidue = button.getText();
        if ("PROTEIN".equals(arg)) {
            String c = (String) conformationComboBox.getSelectedItem();
            if (!c.toUpperCase().startsWith("DEFAULT")) {
                c = c.substring(c.indexOf("[") + 1, c.indexOf("]"));
                newResidue = newResidue + " " + c;
            }
            acidComboBox.insertItemAt("" + index + " " + newResidue, index + 1);
            index++;
        } else {
            if (!newResidue.equalsIgnoreCase("MOL")) {
                acidComboBox.insertItemAt("" + index + " " + newResidue, index + 1);
                index++;
            } else if (!selected.equalsIgnoreCase("MOL")) {
                acidComboBox.insertItemAt("" + index + " " + newResidue, index + 1);
                index++;
            }
        }
    }
    // Create the condensed sequence view.
    StringBuilder sequence = new StringBuilder();
    for (int i = 0; i < acidComboBox.getItemCount(); i++) {
        String s[] = ((String) acidComboBox.getItemAt(i)).trim().toUpperCase().split(" +");
        if (s.length > 1) {
            if (s[1].equalsIgnoreCase("MOL")) {
                sequence.append(s[1]).append("\n");
            } else {
                sequence.append(s[1]).append(" ");
            }
        }
    }
    // Renumber the sequence.
    acidTextArea.setText(sequence.toString());
    for (int i = 0; i < acidComboBox.getItemCount(); i++) {
        String s = (String) acidComboBox.getItemAt(i);
        s = s.substring(s.indexOf(" "), s.length()).trim();
        acidComboBox.removeItemAt(i);
        acidComboBox.insertItemAt("" + (i + 1) + " " + s, i);
    }
    // Set the selected entry and fill in the edit textField.
    if (index < 0) {
        index = 0;
    }
    if (index > acidComboBox.getItemCount() - 1) {
        index = acidComboBox.getItemCount() - 1;
    }
    acidComboBox.setSelectedIndex(index);
    String s = (String) acidComboBox.getItemAt(index);
    if (s != null) {
        acidTextField.setText(s.substring(s.indexOf(" "), s.length()).trim());
    } else {
        acidTextField.setText("");
    }
}