Example usage for javax.swing.event DocumentListener DocumentListener

List of usage examples for javax.swing.event DocumentListener DocumentListener

Introduction

In this page you can find the example usage for javax.swing.event DocumentListener DocumentListener.

Prototype

DocumentListener

Source Link

Usage

From source file:au.org.ala.delta.intkey.ui.FindInTaxaDialog.java

public FindInTaxaDialog(Intkey intkeyApp) {
    super(intkeyApp.getMainFrame(), false);
    setResizable(false);/*from   w  w w  . ja va 2s.  c  o  m*/

    ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(FindInTaxaDialog.class);
    resourceMap.injectFields(this);
    ActionMap actionMap = Application.getInstance().getContext().getActionMap(this);

    _intkeyApp = intkeyApp;

    _numMatchedTaxa = 0;
    _currentMatchedTaxon = -1;

    _findAction = actionMap.get("findTaxa");
    _nextAction = actionMap.get("nextFoundTaxon");

    this.setTitle(windowTitle);

    getContentPane().setLayout(new BorderLayout(0, 0));

    _pnlMain = new JPanel();
    _pnlMain.setBorder(new EmptyBorder(20, 20, 20, 20));
    getContentPane().add(_pnlMain, BorderLayout.CENTER);
    _pnlMain.setLayout(new BorderLayout(0, 0));

    _pnlMainTop = new JPanel();
    _pnlMain.add(_pnlMainTop, BorderLayout.NORTH);
    _pnlMainTop.setLayout(new BoxLayout(_pnlMainTop, BoxLayout.Y_AXIS));

    _lblEnterSearchString = new JLabel(enterSearchStringCaption);
    _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 5, 0));
    _lblEnterSearchString.setHorizontalAlignment(SwingConstants.LEFT);
    _lblEnterSearchString.setVerticalAlignment(SwingConstants.TOP);
    _lblEnterSearchString.setAlignmentY(Component.TOP_ALIGNMENT);
    _pnlMainTop.add(_lblEnterSearchString);

    _textField = new JTextField();
    _textField.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            reset();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            reset();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            reset();
        }
    });

    _pnlMainTop.add(_textField);
    _textField.setColumns(10);

    _pnlMainMiddle = new JPanel();
    _pnlMainMiddle.setBorder(new EmptyBorder(10, 0, 0, 0));
    _pnlMain.add(_pnlMainMiddle, BorderLayout.CENTER);
    _pnlMainMiddle.setLayout(new BoxLayout(_pnlMainMiddle, BoxLayout.Y_AXIS));

    _rdbtnSelectOne = new JRadioButton(selectOneCaption);
    _rdbtnSelectOne.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });
    _pnlMainMiddle.add(_rdbtnSelectOne);

    _rdbtnSelectAll = new JRadioButton(selectAllCaption);
    _rdbtnSelectAll.setSelected(true);
    _rdbtnSelectAll.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });
    _pnlMainMiddle.add(_rdbtnSelectAll);

    ButtonGroup radioButtonGroup = new ButtonGroup();
    radioButtonGroup.add(_rdbtnSelectOne);
    radioButtonGroup.add(_rdbtnSelectAll);

    _pnlMainBottom = new JPanel();
    _pnlMain.add(_pnlMainBottom, BorderLayout.SOUTH);
    _pnlMainBottom.setLayout(new BoxLayout(_pnlMainBottom, BoxLayout.Y_AXIS));

    _chckbxSearchSynonyms = new JCheckBox(searchSynonymsCaption);
    _chckbxSearchSynonyms.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });

    _pnlMainBottom.add(_chckbxSearchSynonyms);

    _chckbxSearchEliminatedTaxa = new JCheckBox(searchEliminatedTaxaCaption);
    _chckbxSearchEliminatedTaxa.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });

    _pnlMainBottom.add(_chckbxSearchEliminatedTaxa);

    _pnlButtons = new JPanel();
    _pnlButtons.setBorder(new EmptyBorder(20, 0, 0, 10));
    getContentPane().add(_pnlButtons, BorderLayout.EAST);
    _pnlButtons.setLayout(new BorderLayout(0, 0));

    _pnlInnerButtons = new JPanel();
    _pnlButtons.add(_pnlInnerButtons, BorderLayout.NORTH);
    GridBagLayout gbl_pnlInnerButtons = new GridBagLayout();
    gbl_pnlInnerButtons.columnWidths = new int[] { 0, 0 };
    gbl_pnlInnerButtons.rowHeights = new int[] { 0, 0, 0, 0 };
    gbl_pnlInnerButtons.columnWeights = new double[] { 0.0, Double.MIN_VALUE };
    gbl_pnlInnerButtons.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
    _pnlInnerButtons.setLayout(gbl_pnlInnerButtons);

    _btnFindNext = new JButton();
    _btnFindNext.setAction(_findAction);
    GridBagConstraints gbc_btnFind = new GridBagConstraints();
    gbc_btnFind.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnFind.insets = new Insets(0, 0, 5, 0);
    gbc_btnFind.gridx = 0;
    gbc_btnFind.gridy = 0;
    _pnlInnerButtons.add(_btnFindNext, gbc_btnFind);

    _btnPrevious = new JButton();
    _btnPrevious.setAction(actionMap.get("previousFoundTaxon"));
    _btnPrevious.setEnabled(false);
    GridBagConstraints gbc_btnPrevious = new GridBagConstraints();
    gbc_btnPrevious.insets = new Insets(0, 0, 5, 0);
    gbc_btnPrevious.gridx = 0;
    gbc_btnPrevious.gridy = 1;
    _pnlInnerButtons.add(_btnPrevious, gbc_btnPrevious);

    _btnDone = new JButton();
    _btnDone.setAction(actionMap.get("findTaxaDone"));
    GridBagConstraints gbc_btnDone = new GridBagConstraints();
    gbc_btnDone.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnDone.gridx = 0;
    gbc_btnDone.gridy = 2;
    _pnlInnerButtons.add(_btnDone, gbc_btnDone);

    this.pack();
    this.setLocationRelativeTo(_intkeyApp.getMainFrame());
}

From source file:au.org.ala.delta.editor.ui.ItemEditor.java

/**
 * Adds the event handlers to the UI components.
 *///from   w  ww  .ja v a  2 s .  c o  m
private void addEventHandlers(ActionMap map) {
    spinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            if (_editsDisabled) {
                return;
            }

            updateItemSelection((Integer) spinner.getValue());
        }
    });

    rtfEditor.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            itemEditPerformed();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            itemEditPerformed();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            itemEditPerformed();
        }
    });
    rtfEditor.addKeyListener(new SelectionNavigationKeyListener() {

        @Override
        protected void advanceSelection() {
            _validator.verify(rtfEditor);
        }

    });
    taxonSelectionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    taxonSelectionList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (_editsDisabled) {
                return;
            }
            _selectedItem = _dataSet.getItem(taxonSelectionList.getSelectedIndex() + 1);
            updateDisplay();
        }
    });

    btnDone.setAction(map.get("itemEditDone"));
    chckbxTreatAsVariant.setAction(map.get("itemVarianceChanged"));
    btnSelect.setAction(map.get("selectItemByName"));
    taxonSelectionList.setSelectionAction(map.get("taxonSelected"));
    _validator = new TextComponentValidator(new ItemValidator(), this);

    // Give the item description text area focus.
    addInternalFrameListener(new InternalFrameAdapter() {
        @Override
        public void internalFrameActivated(InternalFrameEvent e) {
            rtfEditor.requestFocusInWindow();
        }
    });
}

From source file:edu.ku.brc.specify.config.init.DBLocationPanel.java

/**
 * Creates a dialog for entering database name and selecting the appropriate driver.
 *//* w  w w .  j a v  a 2 s.co m*/
public DBLocationPanel(final JButton nextBtn) {
    super("Storage", null, nextBtn, null);

    localDirOK = true;
    File currentPath = new File(UIRegistry.getAppDataDir() + File.separator + "specify_tmp.tmp");
    try {
        FileUtils.touch(currentPath);
        currentPath.delete();

    } catch (IOException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DBLocationPanel.class, ex);
        localDirOK = false;
    }

    //localDirOK = false ; // XXX TESTING

    ButtonGroup grp = new ButtonGroup();
    useHomeRB = new JRadioButton(
            "<html>Use your home directory: <b>" + UIRegistry.getUserHomeAppDir() + "</b></html>");
    grp.add(useHomeRB);
    useHomeRB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (browse != null) {
                browse.setEnabled(false);
            }
            updateBtnUI();
        }
    });

    int numRows = 3;
    StringBuilder header = new StringBuilder(
            "<html>This step requires you to select a storage for the database.");
    //localDirOK = false; // DEBUG
    if (localDirOK) {
        header.append("There are three options:</html>");

        useCurrentRB = new JRadioButton(
                "<html>Use your current directory: <b>" + UIRegistry.getDefaultWorkingPath() + "</b></html>");
        grp.add(useCurrentRB);
        useCurrentRB.setSelected(true);
        numRows++;

    } else {
        header.append(
                "<br>The database cannot be stored on the media you are currently running Workbench from, ");
        header.append(
                "so you can allow it to default to your '<i>home</i>' directory. Or choose a different storage.</html>");
        useHomeRB.setSelected(true);
    }

    useUserDefinedRB = new JRadioButton("Use other storage:");
    grp.add(useUserDefinedRB);
    useUserDefinedRB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            browse.setEnabled(true);
            updateBtnUI();
        }
    });

    filePath = new JTextField(30);
    filePath.getDocument().addDocumentListener(new DocumentListener() {
        public void insertUpdate(DocumentEvent e) {
            updateBtnUI();
        }

        public void removeUpdate(DocumentEvent e) {
            updateBtnUI();
        }

        public void changedUpdate(DocumentEvent e) {
            updateBtnUI();
        }
    });
    browse = new BrowseBtnPanel(filePath, true, true);
    browse.setEnabled(false);

    CellConstraints cc = new CellConstraints();

    JLabel lbl = new JLabel(header.toString());
    PanelBuilder cmtBldr = new PanelBuilder(new FormLayout("f:min(300px;p):g", "f:p:g"));
    cmtBldr.add(lbl, cc.xy(1, 1));

    PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,p:g",
            "p:g,2px," + UIHelper.createDuplicateJGoodiesDef("p", "2px", numRows) + ",f:p:g"), this);
    int row = 1;

    builder.add(cmtBldr.getPanel(), cc.xywh(1, row, 3, 1));
    row += 2;
    builder.add(useHomeRB, cc.xy(1, row));
    row += 2;
    if (useCurrentRB != null) {
        builder.add(useCurrentRB, cc.xy(1, row));
        row += 2;
    }
    builder.add(useUserDefinedRB, cc.xy(1, row));
    row += 2;
    builder.add(browse, cc.xy(1, row));
    row += 2;

}

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

public BlueprintChooserComponent() {
    filterThread = new DelayedMethodInvokerThread(200) {

        @Override//w w  w. ja  v a2s  .  c o  m
        protected void invokeDelayedMethod() throws Exception {
            SwingUtilities.invokeAndWait(new Runnable() {

                @Override
                public void run() {
                    nameFilterChanged();
                }
            });
        }

    };
    filterThread.start();

    byNameTextField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            filterThread.eventOccured();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            filterThread.eventOccured();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            filterThread.eventOccured();
        }
    });

    this.treeModelBuilder = new BlueprintTreeModelBuilder(this.dataModelProvider) {
        @Override
        protected List<InventoryType> getMembers(MarketGroup group) {
            final String name = byNameTextField.getText();
            if (name != null && name.length() >= MIN_NAME_LENGTH) {
                substringFilterUsed = true;
                return dataModelProvider.getStaticDataModel().getInventoryTypesWithBlueprints(group, name);
            }
            return dataModelProvider.getStaticDataModel().getInventoryTypesWithBlueprints(group);
        }

        @Override
        protected IViewFilter<ITreeNode> getViewFilter() {
            final IViewFilter<ITreeNode> superFilter = super.getViewFilter();
            return new AbstractViewFilter<ITreeNode>() {

                @Override
                public boolean isHiddenUnfiltered(ITreeNode value) {
                    if (superFilter.isHidden(value)) {
                        return true;
                    }

                    final String name = byNameTextField.getText();
                    if (name != null && name.length() >= MIN_NAME_LENGTH) {
                        final Blueprint bp = getSelectedBlueprint(value);
                        return bp != null && !bp.getName().toLowerCase().contains(name.toLowerCase());
                    }
                    return false;
                }
            };
        }
    };
    this.treeModelBuilder.attach(tree);
}

From source file:com.microsoft.alm.plugin.idea.ui.vcsimport.ImportForm.java

private void ensureInitialized() {
    if (!initialized) {
        // Ensure that the commands are set up correctly
        teamProjectFilter.setActionCommand(CMD_PROJECT_FILTER_CHANGED);
        refreshButton.setActionCommand(CMD_REFRESH);

        // Fix HiDPI scaling for table
        SwingHelper.scaleTableRowHeight(teamProjectTable);

        // Fix tabbing in table
        SwingHelper.fixTabKeys(teamProjectTable);

        // Set help text and popup text
        helpPanel.addPopupCommand(TfPluginBundle.message(TfPluginBundle.KEY_VSO_LOOKUP_HELP_ENTER_URL),
                CMD_GOTO_TFS);/*from ww  w . ja va  2 s  .  com*/
        helpPanel.addPopupCommand(TfPluginBundle.message(TfPluginBundle.KEY_VSO_LOOKUP_HELP_VIEW_ACCOUNTS),
                CMD_GOTO_SPS_PROFILE);
        helpPanel.setVisible(false); // Don't show this help panel until we know if it's vs.com

        // Set hint text
        teamProjectFilter.setUI(
                new HintTextFieldUI(TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_DIALOG_FILTER_HINT)));

        // Align the busy spinner and the refresh button with the height of the text box
        refreshButton.putClientProperty("JButton.buttonType", "square"); // This is a magical property that tells IntelliJ to draw the button like an image button
        final int textBoxHeight = (int) teamProjectFilter.getPreferredSize().getHeight();
        final Dimension size = new Dimension(textBoxHeight, textBoxHeight);
        refreshButton.setMinimumSize(size);
        refreshButton.setPreferredSize(size);
        busySpinner.setMinimumSize(size);
        busySpinner.setPreferredSize(size);

        // Setup document events for filter
        // Using a timer so that we don't respond to every character typed
        // The timer is created in the create components method
        teamProjectFilter.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                onFilterChanged();
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                onFilterChanged();
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
                onFilterChanged();
            }

            private void onFilterChanged() {
                if (timer.isRunning()) {
                    timer.restart();
                } else {
                    timer.start();
                }
            }
        });

        teamProjectScrollPane.setMinimumSize(new Dimension(JBUI.scale(200), JBUI.scale(70)));
        teamProjectTable.setRowHeight(teamProjectTable.getFontMetrics(teamProjectTable.getFont()).getHeight());

        initialized = true;
    }
}

From source file:de.tbuchloh.kiskis.gui.widgets.PasswordElement.java

/**
 * @param pwd//  w w  w.  j a  va 2s . c o  m
 *            the password to edit
 */
public PasswordElement(final char[] pwd) {
    _pwdField = new JPasswordField(new String(pwd));
    _pwdField.setFont(createFont());
    _pwdField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void changedUpdate(final DocumentEvent e) {
            notifyListeners();
        }

        @Override
        public void insertUpdate(final DocumentEvent e) {
            notifyListeners();
        }

        @Override
        public void removeUpdate(final DocumentEvent e) {
            notifyListeners();
        }
    });
    _pwdButton = new LinkLabel(M.createAction(this, "onShowPassword"));
    _pwdButton.setHorizontalAlignment(SwingConstants.RIGHT);

    _testButton = new LinkLabel(M.createAction(this, "onTestPassword"));
    _testButton.setHorizontalAlignment(SwingConstants.RIGHT);

    _mode = HIDDEN;

    _progressBar = new PasswordQualityBar();
    _progressBar.setSmallFont();

    init();
    initCreatePopup();
}

From source file:com.smart.aqimonitor.client.AqiMonitor.java

/**
 * Create the frame.//from   ww w  .ja  va 2 s. c o  m
 */
public AqiMonitor() {
    refSelf = this;
    setPreferredSize(new Dimension(640, 480));
    setTitle("\u7A7A\u6C14\u8D28\u91CF\u76D1\u6D4B");
    setIconImage(Toolkit.getDefaultToolkit()
            .getImage(AqiMonitor.class.getResource("/lombok/installer/eclipse/STS.png")));
    setMinimumSize(new Dimension(640, 480));
    setMaximumSize(new Dimension(1024, 768));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 636, 412);
    contentPane = new JPanel();
    contentPane.setPreferredSize(new Dimension(640, 480));
    contentPane.setMinimumSize(new Dimension(640, 480));
    contentPane.setMaximumSize(new Dimension(1024, 768));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

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

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

    JScrollPane scrollPane = new JScrollPane();
    scrollPane
            .setViewportBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    contentPanel.add(scrollPane, BorderLayout.CENTER);

    textPane = new AqiTextPane();
    textPane.addInputMethodListener(new InputMethodListener() {

        public void caretPositionChanged(InputMethodEvent event) {

        }

        public void inputMethodTextChanged(InputMethodEvent event) {
            textPane.setCaretPosition(document.getLength() + 1);
        }
    });
    textPane.setEditable(false);
    textPane.setOpaque(false);
    textPane.setForeground(Color.BLACK);
    scrollPane.setViewportView(textPane);
    document = textPane.getStyledDocument();

    document.addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            if (e.getDocument() == document) {
                textPane.setCaretPosition(document.getLength());
            }
        }
    });

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

    JLabel lblTipsLabel = new JLabel(
            "Tips\uFF1A\u6587\u4EF6\u4FDD\u5B58\u683C\u5F0Fcsv\u53EF\u7528Excel\u6253\u5F00");
    lblTipsLabel.setForeground(Color.BLUE);
    buttonPanel.add(lblTipsLabel, BorderLayout.WEST);

    JPanel panel = new JPanel();
    buttonPanel.add(panel, BorderLayout.CENTER);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton btnRetrieve = new JButton("\u624B\u52A8\u83B7\u53D6\u6570\u636E");
    panel.add(btnRetrieve);
    btnRetrieve.setVerticalAlignment(SwingConstants.BOTTOM);

    JButton btnNewButton = new JButton("\u5173\u4E8E");
    btnNewButton.setToolTipText("\u5173\u4E8E");
    btnNewButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JTextArea textArea = new JTextArea(
                    "\n        csv\n\n        smartstudio@foxmail.com");
            textArea.setColumns(35);
            textArea.setRows(6);
            textArea.setLineWrap(true);// 
            textArea.setEditable(false);// 
            textArea.setOpaque(false);
            JOptionPane.showMessageDialog(contentPane, textArea, "", JOptionPane.PLAIN_MESSAGE);
        }
    });

    JButton btnSetting = new JButton("\u8BBE\u7F6E");
    btnSetting.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            Point parentPos = refSelf.getLocation();

            AqiSettingDialog settingDialog = new AqiSettingDialog(refSelf, pm25InDetailJob.getAqiParser());
            settingDialog.setModal(true);
            settingDialog.setLocation(parentPos.x + 100, parentPos.y + 150);
            settingDialog.init();
            settingDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            settingDialog.setVisible(true);
        }
    });

    JButton btnExportDir = new JButton("\u67E5\u770B\u6570\u636E");
    btnExportDir.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {

                String[] cmd = new String[5];

                String filePath = pm25InDetailJob.getAqiParser().getFilePath();
                File file = new File(filePath);
                if (!file.exists()) {
                    FileUtil.makeDir(file);
                }
                if (!file.isDirectory()) {
                    JOptionPane.showMessageDialog(contentPane, "", "",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                cmd[0] = "cmd";
                cmd[1] = "/c";
                cmd[2] = "start";
                cmd[3] = " ";
                cmd[4] = pm25InDetailJob.getAqiParser().getFilePath();

                Runtime.getRuntime().exec(cmd);

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
    panel.add(btnExportDir);
    panel.add(btnSetting);
    panel.add(btnNewButton);
    btnRetrieve.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!isRetrieving) {
                isRetrieving = true;
                Thread firstRun = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        pm25InDetailJob.refresh();
                        isRetrieving = false;
                    }
                });

                firstRun.start();
            }
        }
    });

    init();
}

From source file:com.microsoft.alm.plugin.idea.git.ui.vcsimport.ImportForm.java

private void ensureInitialized() {
    if (!initialized) {
        // Ensure that the commands are set up correctly
        teamProjectFilter.setActionCommand(CMD_PROJECT_FILTER_CHANGED);
        refreshButton.setActionCommand(CMD_REFRESH);

        // Fix HiDPI scaling for table
        SwingHelper.scaleTableRowHeight(teamProjectTable);

        // Fix tabbing in table
        SwingHelper.fixTabKeys(teamProjectTable);
        teamProjectTable.addFocusListener(new TableFocusListener(teamProjectTable));

        // Set help text and popup text
        helpPanel.addPopupCommand(TfPluginBundle.message(TfPluginBundle.KEY_VSO_LOOKUP_HELP_ENTER_URL),
                CMD_GOTO_TFS);/* www .  ja va  2 s  .com*/
        helpPanel.addPopupCommand(TfPluginBundle.message(TfPluginBundle.KEY_VSO_LOOKUP_HELP_VIEW_ACCOUNTS),
                CMD_GOTO_SPS_PROFILE);
        helpPanel.setVisible(false); // Don't show this help panel until we know if it's vs.com

        // Set hint text
        teamProjectFilter.setUI(
                new HintTextFieldUI(TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_DIALOG_FILTER_HINT)));

        // Align the busy spinner and the refresh button with the height of the text box
        refreshButton.putClientProperty("JButton.buttonType", "square"); // This is a magical property that tells IntelliJ to draw the button like an image button
        final int textBoxHeight = (int) teamProjectFilter.getPreferredSize().getHeight();
        final Dimension size = new Dimension(textBoxHeight, textBoxHeight);
        refreshButton.setMinimumSize(size);
        refreshButton.setPreferredSize(size);
        busySpinner.setMinimumSize(size);
        busySpinner.setPreferredSize(size);

        // Setup document events for filter
        // Using a timer so that we don't respond to every character typed
        // The timer is created in the create components method
        teamProjectFilter.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                onFilterChanged();
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                onFilterChanged();
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
                onFilterChanged();
            }

            private void onFilterChanged() {
                if (timer.isRunning()) {
                    timer.restart();
                } else {
                    timer.start();
                }
            }
        });

        teamProjectScrollPane.setMinimumSize(new Dimension(JBUI.scale(200), JBUI.scale(70)));
        teamProjectTable.setRowHeight(teamProjectTable.getFontMetrics(teamProjectTable.getFont()).getHeight());

        initialized = true;
    }
}

From source file:com.mirth.connect.connectors.http.HttpSender.java

public HttpSender() {
    this.parent = PlatformUI.MIRTH_FRAME;
    initComponents();/*from  w w w .  j  a  v  a 2 s .  c o m*/

    parent.setupCharsetEncodingForConnector(charsetEncodingCombobox);

    queryParametersPane.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            deselectRows(queryParametersTable, queryParametersDeleteButton);
        }
    });
    headersPane.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            deselectRows(headersTable, headersDeleteButton);
        }
    });
    queryParametersDeleteButton.setEnabled(false);
    headersDeleteButton.setEnabled(false);

    urlField.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent evt) {
            urlFieldChanged();
        }
    });

    sslWarningPanel = new SSLWarningPanel();

    contentTypeField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            checkContentEnabled();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            checkContentEnabled();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            checkContentEnabled();
        }
    });
}

From source file:cz.alej.michalik.totp.client.AddDialog.java

public AddDialog(final Properties prop) {
    System.out.println("Pridat novy zaznam");
    this.setTitle("Pidat");
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.setMinimumSize(new Dimension(600, 150));
    this.setLocationByPlatform(true);
    // Panel pro vytvoen okraj
    JPanel panel = new JPanel();
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));
    panel.setLayout(new GridBagLayout());
    // Vlastnosti pro popisky
    GridBagConstraints label = new GridBagConstraints();
    label.insets = new Insets(2, 2, 2, 2);
    label.fill = GridBagConstraints.NONE;
    label.weightx = 1;/*from  w  w w .j  av  a2 s. c  o  m*/
    // Vlastnosti pro pole
    GridBagConstraints field = new GridBagConstraints();
    field.insets = new Insets(2, 2, 2, 2);
    field.fill = GridBagConstraints.HORIZONTAL;
    field.weightx = 10;

    this.add(panel);

    // Nastavm ikonu okna
    try {
        String path = "/material-design-icons/content/drawable-xhdpi/ic_create_black_48dp.png";
        this.setIconImage(Toolkit.getDefaultToolkit().getImage(App.class.getResource(path)));
    } catch (NullPointerException ex) {
        System.out.println("Icon not found");
    }

    // Pole pro pojmenovn zznamu
    // Ikona
    ImageIcon icon = null;
    try {
        String path = "/material-design-icons/editor/drawable-xhdpi/ic_format_color_text_black_18dp.png";
        icon = new ImageIcon(App.class.getResource(path));
    } catch (NullPointerException ex) {
        System.out.println("Icon not found");
    }
    // Pidn labelu s ikonou a nastavm velikost psma
    label.gridy = 0;
    field.gridy = 0;
    JLabel nameLabel = new JLabel("Nzev: ", icon, JLabel.CENTER);
    nameLabel.setFont(nameLabel.getFont().deriveFont(App.FONT_SIZE * 2 / 3));
    panel.add(nameLabel, label);
    // Pole pro jmno
    final JTextField name = new JTextField();
    name.setMaximumSize(new Dimension(Integer.MAX_VALUE, 50));
    name.setFont(name.getFont().deriveFont(App.FONT_SIZE * 2 / 3));
    panel.add(name, field);

    // Pole pro zadn sdlenho hesla
    // Ikona
    icon = null;
    try {
        String path = "/material-design-icons/hardware/drawable-xhdpi/ic_security_black_18dp.png";
        icon = new ImageIcon(App.class.getResource(path));
    } catch (NullPointerException ex) {
        System.out.println("Icon not found");
    }
    // Pidn labelu s ikonou
    label.gridy = 1;
    field.gridy = 1;
    JLabel secretLabel = new JLabel("Heslo: ", icon, JLabel.CENTER);
    secretLabel.setFont(secretLabel.getFont().deriveFont(App.FONT_SIZE * 2 / 3));
    panel.add(secretLabel, label);
    // Pole pro heslo
    final JTextField secret = new JTextField();
    secret.setMaximumSize(new Dimension(Integer.MAX_VALUE, 50));
    secret.setFont(secret.getFont().deriveFont(App.FONT_SIZE * 2 / 3));
    panel.add(secret, field);

    this.setVisible(true);

    // Akce pro odesln formule
    ActionListener submit = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            submit(prop, name, secret, false);
        }
    };

    // Pi stisku klvesy Enter odele formul
    name.addActionListener(submit);
    secret.addActionListener(submit);
    // Pi zmn pole pro heslo se vstup okamit zformtuje
    final Runnable sanitizer = new Runnable() {
        @Override
        public void run() {
            sanitize(secret);

        }
    };
    secret.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            SwingUtilities.invokeLater(sanitizer);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
        }
    });

    // Pi zaven okna odele formul
    this.addWindowListener(new WindowListener() {

        @Override
        public void windowOpened(WindowEvent e) {
            // Ignorovat

        }

        @Override
        public void windowIconified(WindowEvent e) {
            // Ignorovat

        }

        @Override
        public void windowDeiconified(WindowEvent e) {
            // Ignorovat

        }

        @Override
        public void windowDeactivated(WindowEvent e) {
            // Ignorovat

        }

        @Override
        public void windowClosing(WindowEvent e) {
            // Odeslat
            submit(prop, name, secret, true);

        }

        @Override
        public void windowClosed(WindowEvent e) {
            // Ignorovat

        }

        @Override
        public void windowActivated(WindowEvent e) {
            // Ignorovat

        }
    });
}