Search in sources :

Example 61 with DocumentListener

use of javax.swing.event.DocumentListener in project JMRI by JMRI.

the class JythonWindow method actionPerformed.

/**
     * Invoking this action via an event triggers display of a file dialog. If a
     * file is selected, it's then invoked as a script.
     *
     */
@Override
public void actionPerformed(ActionEvent e) {
    pref = InstanceManager.getDefault(UserPreferencesManager.class);
    f = new JmriJFrame(Bundle.getMessage("TitleOutputFrame"));
    f.getContentPane().add(new JScrollPane(area = new javax.swing.JTextArea(ScriptOutput.getDefault().getOutputArea().getDocument(), null, 12, 50), ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    // Add checkbox to enable/disable auto-scrolling
    JPanel p = new JPanel();
    p.add(clearButton = new JButton(Bundle.getMessage("ButtonClear")));
    p.add(autoScroll = new JCheckBox(Bundle.getMessage("CheckBoxAutoScroll"), true));
    autoScroll.setSelected(pref.getSimplePreferenceState(alwaysScrollCheck));
    alwaysOnTopCheckBox.setText("Window always on Top");
    alwaysOnTopCheckBox.setVisible(true);
    alwaysOnTopCheckBox.setToolTipText("If checked, this window be always be displayed in front of any other window");
    alwaysOnTopCheckBox.setSelected(pref.getSimplePreferenceState(alwaysOnTopCheck));
    p.add(alwaysOnTopCheckBox);
    f.setAlwaysOnTop(alwaysOnTopCheckBox.isSelected());
    autoScroll.addItemListener(new ItemListener() {

        // Reference to the JTextArea of this instantiation
        JTextArea ta = area;

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                doAutoScroll(ta, true);
                pref.setSimplePreferenceState(alwaysScrollCheck, autoScroll.isSelected());
            }
        }
    });
    alwaysOnTopCheckBox.addActionListener((ActionEvent ae) -> {
        f.setAlwaysOnTop(alwaysOnTopCheckBox.isSelected());
        pref.setSimplePreferenceState(alwaysOnTopCheck, alwaysOnTopCheckBox.isSelected());
    });
    clearButton.addActionListener((ActionEvent ae) -> {
        area.setText("");
    });
    f.getContentPane().add(p, BorderLayout.PAGE_END);
    // set a monospaced font
    int size = area.getFont().getSize();
    area.setFont(new Font("Monospaced", Font.PLAIN, size));
    // Add document listener to scroll to end when modified
    area.getDocument().addDocumentListener(new DocumentListener() {

        // References to the JTextArea and JCheckBox
        // of this instantiation
        JTextArea ta = area;

        JCheckBox chk = autoScroll;

        @Override
        public void insertUpdate(DocumentEvent e) {
            doAutoScroll(ta, chk.isSelected());
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            doAutoScroll(ta, chk.isSelected());
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            doAutoScroll(ta, chk.isSelected());
        }
    });
    // Scroll to end of document
    doAutoScroll(area, true);
    f.pack();
    f.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) ItemEvent(java.awt.event.ItemEvent) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) DocumentEvent(javax.swing.event.DocumentEvent) UserPreferencesManager(jmri.UserPreferencesManager) Font(java.awt.Font) JCheckBox(javax.swing.JCheckBox) JmriJFrame(jmri.util.JmriJFrame) ItemListener(java.awt.event.ItemListener) JTextArea(javax.swing.JTextArea)

Example 62 with DocumentListener

use of javax.swing.event.DocumentListener in project JMRI by JMRI.

the class AddProfileDialog method initComponents.

/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    lblProfileNameAndLocation = new JLabel();
    jSeparator2 = new JSeparator();
    profileName = new JTextField();
    lblProfileName = new JLabel();
    lblProfileLocation = new JLabel();
    profileLocation = new JTextField();
    profileFolder = new JTextField();
    btnBrowse = new JButton();
    lblProfileFolder = new JLabel();
    jSeparator1 = new JSeparator();
    btnCancel = new JButton();
    btnOk = new JButton();
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    // NOI18N
    ResourceBundle bundle = ResourceBundle.getBundle("jmri/profile/Bundle");
    // NOI18N
    setTitle(bundle.getString("AddProfileDialog.title"));
    setMinimumSize(new Dimension(413, 239));
    lblProfileNameAndLocation.setFont(lblProfileNameAndLocation.getFont().deriveFont(lblProfileNameAndLocation.getFont().getStyle() | Font.BOLD));
    // NOI18N
    lblProfileNameAndLocation.setText(bundle.getString("AddProfileDialog.lblProfileNameAndLocation.text"));
    profileName.setText("");
    profileName.getDocument().addDocumentListener(new DocumentListener() {

        public void changedUpdate(DocumentEvent e) {
            profileNameActionPerformed(null);
        }

        public void insertUpdate(DocumentEvent e) {
            profileNameActionPerformed(null);
        }

        public void removeUpdate(DocumentEvent e) {
            profileNameActionPerformed(null);
        }
    });
    profileName.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent evt) {
            profileNameFocusLost(evt);
        }
    });
    profileName.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            profileNameActionPerformed(evt);
        }
    });
    profileName.addKeyListener(new KeyAdapter() {

        public void keyTyped(KeyEvent evt) {
            profileNameKeyTyped(evt);
        }
    });
    // NOI18N
    lblProfileName.setText(bundle.getString("AddProfileDialog.lblProfileName.text"));
    // NOI18N
    lblProfileLocation.setText(bundle.getString("AddProfileDialog.lblProfileLocation.text"));
    profileLocation.setText(ProfileManager.getDefault().getDefaultSearchPath().getPath());
    profileLocation.setMinimumSize(new Dimension(14, 128));
    profileLocation.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent evt) {
            profileLocationFocusLost(evt);
        }
    });
    profileLocation.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            profileLocationActionPerformed(evt);
        }
    });
    profileLocation.addKeyListener(new KeyAdapter() {

        public void keyTyped(KeyEvent evt) {
            profileLocationKeyTyped(evt);
        }
    });
    profileFolder.setEditable(false);
    profileFolder.setText(ProfileManager.getDefault().getDefaultSearchPath().getPath());
    profileFolder.setEnabled(false);
    profileFolder.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            profileFolderActionPerformed(evt);
        }
    });
    // NOI18N
    btnBrowse.setText(bundle.getString("AddProfileDialog.btnBrowse.text"));
    btnBrowse.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            btnBrowseActionPerformed(evt);
        }
    });
    // NOI18N
    lblProfileFolder.setText(bundle.getString("AddProfileDialog.lblProfileFolder.text"));
    // NOI18N
    btnCancel.setText(bundle.getString("AddProfileDialog.btnCancel.text"));
    btnCancel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            btnCancelActionPerformed(evt);
        }
    });
    // NOI18N
    btnOk.setText(bundle.getString("AddProfileDialog.btnOk.text"));
    btnOk.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            btnOkActionPerformed(evt);
        }
    });
    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jSeparator2).addGroup(layout.createSequentialGroup().addGap(6, 6, 6).addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(lblProfileName).addGap(24, 24, 24).addComponent(profileName, GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(lblProfileLocation).addComponent(lblProfileFolder)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(profileFolder).addComponent(profileLocation, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(btnBrowse)).addGroup(layout.createSequentialGroup().addComponent(lblProfileNameAndLocation).addGap(0, 0, Short.MAX_VALUE)).addComponent(jSeparator1).addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(btnOk).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(btnCancel))).addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(lblProfileNameAndLocation).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(jSeparator2, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(profileName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(lblProfileName)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(profileLocation, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(btnBrowse).addComponent(lblProfileLocation)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(profileFolder, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(lblProfileFolder)).addGap(18, 18, 18).addComponent(jSeparator1, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(btnCancel).addComponent(btnOk)).addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    pack();
}
Also used : DocumentListener(javax.swing.event.DocumentListener) FocusAdapter(java.awt.event.FocusAdapter) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent) FocusEvent(java.awt.event.FocusEvent) JSeparator(javax.swing.JSeparator) KeyEvent(java.awt.event.KeyEvent) ActionListener(java.awt.event.ActionListener) GroupLayout(javax.swing.GroupLayout) ResourceBundle(java.util.ResourceBundle)

Example 63 with DocumentListener

use of javax.swing.event.DocumentListener in project pcgen by PCGen.

the class DiceBagView method initComponents.

/**
	 * <p>Initializes the view and all components, and starts the bag in
	 * editing mode.  It sets the size ({@code pack()}) of the
	 * internal frame, but does <b>not</b> show the frame.</p>
	 *
	 *
	 */
private void initComponents() {
    /*
		 *     /////////////////////////////////
		 *     // Expr [             ] [roll] //
		 *     // |RESULT            | [edit] //
		 *     /////////////////////////////////
		 *     //  [ expr ] [ expr ] [ expr ] //
		 *     //  [ expr ] [ expr ] [ expr ] //
		 *     //  [ expr ] [ expr ] [ expr ] //
		 *     //  [ expr ] [ expr ] [ expr ] //
		 *     //  [ expr ] [ expr ] [ expr ] //
		 *     //  [ expr ] [ expr ] [ expr ] //
		 *     /////////////////////////////////
		 */
    // Set basic properties
    setTitle(m_bag.getName());
    setResizable(true);
    setClosable(true);
    setMaximizable(true);
    setIconifiable(true);
    // Assure main panes content borderlayout
    getContentPane().setLayout(new BorderLayout());
    //Create all JPanels
    m_top = new JPanel();
    m_topTop = new JPanel();
    m_topBottom = new JPanel();
    m_center = new JPanel();
    //Set Layout managers for all panels
    m_top.setLayout(new GridLayout(2, 1));
    m_topTop.setLayout(new BoxLayout(m_topTop, BoxLayout.X_AXIS));
    m_topBottom.setLayout(new BoxLayout(m_topBottom, BoxLayout.X_AXIS));
    m_center.setLayout(new DiceBagGridLayout(0, 3, DiceBagGridLayout.MANAGE_BY_COLUMNS, 75, 100));
    m_center.setBorder(new EmptyBorder(5, 5, 5, 5));
    //Rolling mode controls
    m_rollButton = new JButton("Roll");
    m_rollButton.setActionCommand("ROLL");
    m_rollButton.addActionListener(m_bagListener);
    m_exprResult = new JLabel(" ");
    m_exprResult.setMinimumSize(new Dimension(50, m_exprResult.getMinimumSize().height));
    m_exprResult.setPreferredSize(new Dimension(50, m_exprResult.getPreferredSize().height));
    m_exprResult.setMaximumSize(new Dimension(Integer.MAX_VALUE, m_exprResult.getMaximumSize().height));
    m_editButton = new JButton("Edit");
    m_editButton.setActionCommand("EDIT");
    m_editButton.addActionListener(m_bagListener);
    m_diceButtons = new ArrayList<>();
    m_exprField = new JTextField();
    m_exprFieldLabel = new JLabel("Roll Expr: ");
    //Components for editing mode
    m_table = new JTable(m_tableModel);
    m_scrollPane = new JScrollPane(m_table);
    /*
		 * stop editing button
		 * delete selected button
		 * move up button
		 * move down button
		 */
    m_stopEditing = new JButton("Stop Editing");
    m_stopEditing.setActionCommand("STOP_EDITING");
    m_stopEditing.addActionListener(m_bagListener);
    m_deleteSelected = new JButton("Delete");
    m_deleteSelected.setActionCommand("DELETE");
    m_deleteSelected.addActionListener(m_bagListener);
    m_moveUp = new JButton("Move up");
    m_moveUp.setActionCommand("MOVE_UP");
    m_moveUp.addActionListener(m_bagListener);
    m_moveDown = new JButton("Move down");
    m_moveDown.setActionCommand("MOVE_DOWN");
    m_moveDown.addActionListener(m_bagListener);
    m_nameField = new JTextField();
    m_nameFieldLabel = new JLabel("Name: ");
    m_nameField.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            m_bag.setName(m_nameField.getText());
            setTitle(m_nameField.getText());
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            m_bag.setName(m_nameField.getText());
            setTitle(m_nameField.getText());
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
        // TODO:  Method doesn't do anything?
        }
    });
    setFrameIcon(Icons.gmgen_icon.getImageIcon());
    //Start in rolling mode
    setupRollingMode();
    //Size and position the window
    pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) EmptyBorder(javax.swing.border.EmptyBorder)

Example 64 with DocumentListener

use of javax.swing.event.DocumentListener in project beast-mcmc by beast-dev.

the class TaxonSetPanel method initPanel.

protected void initPanel(Action addTaxonSetAction, Action removeTaxonSetAction) {
    JScrollPane scrollPane1 = new JScrollPane(taxonSetsTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    ActionPanel actionPanel1 = new ActionPanel(false);
    actionPanel1.setAddAction(addTaxonSetAction);
    actionPanel1.setRemoveAction(removeTaxonSetAction);
    addTaxonSetAction.setEnabled(false);
    removeTaxonSetAction.setEnabled(false);
    JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    controlPanel1.add(actionPanel1);
    // Excluded Taxon List
    excludedTaxaTableModel = new TaxaTableModel(false);
    excludedTaxaTable = new JTable(excludedTaxaTableModel);
    excludedTaxaTable.getColumnModel().getColumn(0).setCellRenderer(new TableRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));
    excludedTaxaTable.getColumnModel().getColumn(0).setMinWidth(20);
    excludedTaxaTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            excludedTaxaTableSelectionChanged();
        }
    });
    JScrollPane scrollPane2 = new JScrollPane(excludedTaxaTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    includedTaxonSetsComboBox = new JComboBox(new String[] { TAXON.toLowerCase() + "..." });
    excludedTaxonSetsComboBox = new JComboBox(new String[] { TAXON.toLowerCase() + "..." });
    includedTaxaLabel.setText("");
    excludedTaxaLabel.setText("");
    Box panel1 = new Box(BoxLayout.X_AXIS);
    panel1.add(new JLabel("Select: "));
    panel1.setOpaque(false);
    excludedTaxonSetsComboBox.setOpaque(false);
    panel1.add(excludedTaxonSetsComboBox);
    // Included Taxon List
    includedTaxaTableModel = new TaxaTableModel(true);
    includedTaxaTable = new JTable(includedTaxaTableModel);
    includedTaxaTable.getColumnModel().getColumn(0).setCellRenderer(new TableRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));
    includedTaxaTable.getColumnModel().getColumn(0).setMinWidth(20);
    includedTaxaTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            includedTaxaTableSelectionChanged();
        }
    });
    includedTaxaTable.doLayout();
    JScrollPane scrollPane3 = new JScrollPane(includedTaxaTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    Box panel2 = new Box(BoxLayout.X_AXIS);
    panel2.add(new JLabel("Select: "));
    panel2.setOpaque(false);
    includedTaxonSetsComboBox.setOpaque(false);
    panel2.add(includedTaxonSetsComboBox);
    Icon includeIcon = null, excludeIcon = null;
    try {
        includeIcon = new ImageIcon(IconUtils.getImage(BeautiApp.class, "images/include.png"));
        excludeIcon = new ImageIcon(IconUtils.getImage(BeautiApp.class, "images/exclude.png"));
    } catch (Exception e) {
    // do nothing
    }
    JPanel buttonPanel = createAddRemoveButtonPanel(includeTaxonAction, includeIcon, "Include selected " + TAXA.toLowerCase() + " in the " + TAXON.toLowerCase(), excludeTaxonAction, excludeIcon, "Exclude selected " + TAXA.toLowerCase() + " from the " + TAXON.toLowerCase(), BoxLayout.Y_AXIS);
    taxonSetEditingPanel = new JPanel();
    taxonSetEditingPanel.setBorder(BorderFactory.createTitledBorder(""));
    taxonSetEditingPanel.setOpaque(false);
    taxonSetEditingPanel.setLayout(new GridBagLayout());
    excludedTaxaSearchField.setColumns(12);
    excludedTaxaSearchField.putClientProperty("JTextField.variant", "search");
    excludedTaxaSearchField.putClientProperty("Quaqua.TextField.style", "search");
    excludedTaxaSearchField.putClientProperty("Quaqua.TextField.sizeVariant", "small");
    includedTaxaSearchField.setColumns(12);
    includedTaxaSearchField.putClientProperty("JTextField.variant", "search");
    includedTaxaSearchField.putClientProperty("Quaqua.TextField.style", "search");
    includedTaxaSearchField.putClientProperty("Quaqua.TextField.sizeVariant", "small");
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.5;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(3, 6, 3, 0);
    taxonSetEditingPanel.add(excludedTaxaSearchField, c);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0.5;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 6, 0, 0);
    taxonSetEditingPanel.add(scrollPane2, c);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0.5;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 6, 3, 0);
    taxonSetEditingPanel.add(excludedTaxaLabel, c);
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 0.5;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 6, 3, 0);
    taxonSetEditingPanel.add(panel1, c);
    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 1;
    c.gridheight = 4;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(12, 2, 12, 4);
    taxonSetEditingPanel.add(buttonPanel, c);
    c.gridx = 2;
    c.gridy = 0;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridheight = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(3, 0, 3, 6);
    taxonSetEditingPanel.add(includedTaxaSearchField, c);
    c.gridx = 2;
    c.gridy = 1;
    c.weightx = 0.5;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 0, 6);
    taxonSetEditingPanel.add(scrollPane3, c);
    c.gridx = 2;
    c.gridy = 2;
    c.weightx = 0.5;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 3, 6);
    taxonSetEditingPanel.add(includedTaxaLabel, c);
    c.gridx = 2;
    c.gridy = 3;
    c.weightx = 0.5;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 3, 6);
    taxonSetEditingPanel.add(panel2, c);
    JPanel panel3 = new JPanel();
    panel3.setOpaque(false);
    panel3.setLayout(new GridBagLayout());
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.5;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 2, 12);
    panel3.add(scrollPane1, c);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(2, 0, 0, 12);
    panel3.add(actionPanel1, c);
    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 0.5;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 0, 0);
    panel3.add(taxonSetEditingPanel, c);
    setOpaque(false);
    setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
    setLayout(new BorderLayout(0, 0));
    add(panel3, BorderLayout.CENTER);
    //		taxonSetsTable.addMouseListener(new MouseAdapter() {
    //			public void mouseClicked(MouseEvent e) {
    //				if (e.getClickCount() == 2) {
    //					JTable target = (JTable)e.getSource();
    //					int row = target.getSelectedRow();
    //					taxonSetsTableDoubleClicked(row);
    //				}
    //			}
    //		});
    includedTaxaSearchField.getDocument().addDocumentListener(new DocumentListener() {

        public void changedUpdate(DocumentEvent e) {
            selectIncludedTaxa(includedTaxaSearchField.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            selectIncludedTaxa(includedTaxaSearchField.getText());
        }

        public void insertUpdate(DocumentEvent e) {
            selectIncludedTaxa(includedTaxaSearchField.getText());
        }
    });
    excludedTaxaSearchField.getDocument().addDocumentListener(new DocumentListener() {

        public void changedUpdate(DocumentEvent e) {
            selectExcludedTaxa(excludedTaxaSearchField.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            selectExcludedTaxa(excludedTaxaSearchField.getText());
        }

        public void insertUpdate(DocumentEvent e) {
            selectExcludedTaxa(excludedTaxaSearchField.getText());
        }
    });
    includedTaxaTable.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                includeSelectedTaxa();
            }
        }
    });
    excludedTaxaTable.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                excludeSelectedTaxa();
            }
        }
    });
    includedTaxaTable.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent focusEvent) {
            excludedTaxaTable.clearSelection();
        }
    });
    excludedTaxaTable.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent focusEvent) {
            includedTaxaTable.clearSelection();
        }
    });
    includedTaxaTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (!includedSelectionChanging) {
                if (includedTaxonSetsComboBox.getSelectedIndex() != 0) {
                    includedTaxonSetsComboBox.setSelectedIndex(0);
                }
                includedTaxaSearchField.setText("");
            }
        }
    });
    includedTaxonSetsComboBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            includedSelectionChanging = true;
            includedTaxaTable.clearSelection();
            if (includedTaxonSetsComboBox.getSelectedIndex() > 0) {
                String taxaName = includedTaxonSetsComboBox.getSelectedItem().toString();
                if (!taxaName.endsWith("...")) {
                    Taxa taxa = options.getTaxa(taxaName);
                    if (taxa != null) {
                        for (int i = 0; i < taxa.getTaxonCount(); i++) {
                            Taxon taxon = taxa.getTaxon(i);
                            int index = includedTaxa.indexOf(taxon);
                            includedTaxaTable.getSelectionModel().addSelectionInterval(index, index);
                        }
                    }
                }
            }
            includedSelectionChanging = false;
        }
    });
    excludedTaxaTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (!excludedSelectionChanging) {
                if (excludedTaxonSetsComboBox.getSelectedIndex() != 0) {
                    excludedTaxonSetsComboBox.setSelectedIndex(0);
                }
                excludedTaxaSearchField.setText("");
            }
        }
    });
    excludedTaxonSetsComboBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            excludedSelectionChanging = true;
            excludedTaxaTable.clearSelection();
            if (excludedTaxonSetsComboBox.getSelectedIndex() > 0) {
                String taxaName = excludedTaxonSetsComboBox.getSelectedItem().toString();
                if (!taxaName.endsWith("...")) {
                    Taxa taxa = options.getTaxa(taxaName);
                    if (taxa != null) {
                        for (int i = 0; i < taxa.getTaxonCount(); i++) {
                            Taxon taxon = taxa.getTaxon(i);
                            int index = excludedTaxa.indexOf(taxon);
                            excludedTaxaTable.getSelectionModel().addSelectionInterval(index, index);
                        }
                    }
                }
            }
            excludedSelectionChanging = false;
        }
    });
    includedTaxaTable.doLayout();
    excludedTaxaTable.doLayout();
}
Also used : DocumentListener(javax.swing.event.DocumentListener) BorderUIResource(javax.swing.plaf.BorderUIResource) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Taxa(dr.evolution.util.Taxa) TableRenderer(jam.table.TableRenderer) Taxon(dr.evolution.util.Taxon) DocumentEvent(javax.swing.event.DocumentEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionPanel(jam.panels.ActionPanel)

Example 65 with DocumentListener

use of javax.swing.event.DocumentListener in project processdash by dtuma.

the class FileSystemLOCDiffPanel method buildConfigPanel.

private Component buildConfigPanel() {
    DocumentListener dl = (DocumentListener) EventHandler.create(DocumentListener.class, this, "recalculateEnablement");
    compareOption = new JRadioButton(getRes("Compare_Two"));
    countOneOption = new JRadioButton(getRes("Count_One"));
    compareOption.setSelected(true);
    new OptionCoordinator();
    fileAPrompt = new JLabel(getRes("Compare_A"));
    fileA = new JTextField();
    fileA.getDocument().addDocumentListener(dl);
    browseA = new JButton(resources.getDlgString("Browse"));
    browseA.addActionListener(this);
    fileB = new JTextField();
    fileB.getDocument().addDocumentListener(dl);
    browseB = new JButton(resources.getDlgString("Browse"));
    browseB.addActionListener(this);
    countIdentical = new JCheckBox(resources.getString("Dialog.Count_Unchanged"));
    countIdentical.setEnabled(false);
    fileBBox = BoxUtils.vbox(hbox(getRes("Compare_B"), GLUE), 5, hbox(PAD, fileB, 5, browseB), GLUE, hbox(PAD, countIdentical, GLUE), GLUE);
    return BoxUtils.vbox(hbox(GLUE, compareOption, GLUE, countOneOption, GLUE), GLUE, hbox(fileAPrompt, 150, GLUE), 5, hbox(PAD, fileA, 5, browseA), GLUE, fileBBox);
}
Also used : JCheckBox(javax.swing.JCheckBox) DocumentListener(javax.swing.event.DocumentListener) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Aggregations

DocumentListener (javax.swing.event.DocumentListener)73 DocumentEvent (javax.swing.event.DocumentEvent)70 JTextField (javax.swing.JTextField)24 ActionEvent (java.awt.event.ActionEvent)21 ActionListener (java.awt.event.ActionListener)19 JLabel (javax.swing.JLabel)19 JPanel (javax.swing.JPanel)18 Dimension (java.awt.Dimension)16 JButton (javax.swing.JButton)13 JCheckBox (javax.swing.JCheckBox)13 GridBagLayout (java.awt.GridBagLayout)9 ChangeEvent (javax.swing.event.ChangeEvent)9 GridBagConstraints (java.awt.GridBagConstraints)8 Box (javax.swing.Box)8 ChangeListener (javax.swing.event.ChangeListener)8 BoxLayout (javax.swing.BoxLayout)7 ZapTextField (org.zaproxy.zap.utils.ZapTextField)7 BorderLayout (java.awt.BorderLayout)6 Insets (java.awt.Insets)6 FocusEvent (java.awt.event.FocusEvent)6