Example usage for javax.swing JTextField setText

List of usage examples for javax.swing JTextField setText

Introduction

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

Prototype

@BeanProperty(bound = false, description = "the text of this component")
public void setText(String t) 

Source Link

Document

Sets the text of this TextComponent to the specified text.

Usage

From source file:com.sec.ose.osi.thread.job.identify.IdentifyThread.java

private void updateJtextFieldIdentifyQueueStatusBar() {

    JTextField statusBar = UISharedData.getInstance().getjTextFieldIdentifyQueueStatusBar();
    if (statusBar == null) {
        return;/*from w  w  w.ja  v a 2s  . c  o m*/
    }

    String message = UISharedData.getInstance().getConnectionInfo() + " - " + IdentifyQueue.getInstance().size()
            + " item(s) are in the queue to be updated on server. ";

    int errorQueueSize = IdentifyErrorQueue.getInstance().size();
    if (errorQueueSize > 0) {
        message += " - with " + errorQueueSize + " error(s) ";
    }

    if (isStopByUser == true) {
        message += " - Thread is not running.";
    } else {
        message += " - Thread is running.";
    }

    statusBar.setText(message);
}

From source file:com.entertailion.java.fling.FlingFrame.java

public FlingFrame(String appId) {
    super();/*from w ww. ja v  a  2 s. c  o  m*/
    this.appId = appId;
    rampClient = new RampClient(this);

    addWindowListener(this);

    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    Locale locale = Locale.getDefault();
    resourceBundle = ResourceBundle.getBundle("com/entertailion/java/fling/resources/resources", locale);
    setTitle(MessageFormat.format(resourceBundle.getString("fling.title"), Fling.VERSION));

    JPanel listPane = new JPanel();
    // show list of ChromeCast devices detected on the local network
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
    JPanel devicePane = new JPanel();
    devicePane.setLayout(new BoxLayout(devicePane, BoxLayout.LINE_AXIS));
    deviceList = new JComboBox();
    deviceList.addActionListener(this);
    devicePane.add(deviceList);
    URL url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/refresh.png");
    ImageIcon icon = new ImageIcon(url, resourceBundle.getString("button.refresh"));
    refreshButton = new JButton(icon);
    refreshButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // refresh the list of devices
            if (deviceList.getItemCount() > 0) {
                deviceList.setSelectedIndex(0);
            }
            discoverDevices();
        }
    });
    refreshButton.setToolTipText(resourceBundle.getString("button.refresh"));
    devicePane.add(refreshButton);
    url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/settings.png");
    icon = new ImageIcon(url, resourceBundle.getString("settings.title"));
    settingsButton = new JButton(icon);
    settingsButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JTextField transcodingExtensions = new JTextField(50);
            transcodingExtensions.setText(transcodingExtensionValues);
            JTextField transcodingParameters = new JTextField(50);
            transcodingParameters.setText(transcodingParameterValues);

            JPanel myPanel = new JPanel(new BorderLayout());
            JPanel labelPanel = new JPanel(new GridLayout(3, 1));
            JPanel fieldPanel = new JPanel(new GridLayout(3, 1));
            myPanel.add(labelPanel, BorderLayout.WEST);
            myPanel.add(fieldPanel, BorderLayout.CENTER);
            labelPanel.add(new JLabel(resourceBundle.getString("transcoding.extensions"), JLabel.RIGHT));
            fieldPanel.add(transcodingExtensions);
            labelPanel.add(new JLabel(resourceBundle.getString("transcoding.parameters"), JLabel.RIGHT));
            fieldPanel.add(transcodingParameters);
            labelPanel.add(new JLabel(resourceBundle.getString("device.manual"), JLabel.RIGHT));
            JPanel devicePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
            final JComboBox manualDeviceList = new JComboBox();
            if (manualServers.size() == 0) {
                manualDeviceList.setVisible(false);
            } else {
                for (DialServer dialServer : manualServers) {
                    manualDeviceList.addItem(dialServer);
                }
            }
            devicePanel.add(manualDeviceList);
            JButton addButton = new JButton(resourceBundle.getString("device.manual.add"));
            addButton.setToolTipText(resourceBundle.getString("device.manual.add.tooltip"));
            addButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    JTextField name = new JTextField();
                    JTextField ipAddress = new JTextField();
                    Object[] message = { resourceBundle.getString("device.manual.name") + ":", name,
                            resourceBundle.getString("device.manual.ipaddress") + ":", ipAddress };

                    int option = JOptionPane.showConfirmDialog(null, message,
                            resourceBundle.getString("device.manual"), JOptionPane.OK_CANCEL_OPTION);
                    if (option == JOptionPane.OK_OPTION) {
                        try {
                            manualServers.add(
                                    new DialServer(name.getText(), InetAddress.getByName(ipAddress.getText())));

                            Object selected = deviceList.getSelectedItem();
                            int selectedIndex = deviceList.getSelectedIndex();
                            deviceList.removeAllItems();
                            deviceList.addItem(resourceBundle.getString("devices.select"));
                            for (DialServer dialServer : servers) {
                                deviceList.addItem(dialServer);
                            }
                            for (DialServer dialServer : manualServers) {
                                deviceList.addItem(dialServer);
                            }
                            deviceList.invalidate();
                            if (selectedIndex > 0) {
                                deviceList.setSelectedItem(selected);
                            } else {
                                if (deviceList.getItemCount() == 2) {
                                    // Automatically select single device
                                    deviceList.setSelectedIndex(1);
                                }
                            }

                            manualDeviceList.removeAllItems();
                            for (DialServer dialServer : manualServers) {
                                manualDeviceList.addItem(dialServer);
                            }
                            manualDeviceList.setVisible(true);
                            storeProperties();
                        } catch (UnknownHostException e1) {
                            Log.e(LOG_TAG, "manual IP address", e1);

                            JOptionPane.showMessageDialog(FlingFrame.this,
                                    resourceBundle.getString("device.manual.invalidip"));
                        }
                    }
                }
            });
            devicePanel.add(addButton);
            JButton removeButton = new JButton(resourceBundle.getString("device.manual.remove"));
            removeButton.setToolTipText(resourceBundle.getString("device.manual.remove.tooltip"));
            removeButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    Object selected = manualDeviceList.getSelectedItem();
                    manualDeviceList.removeItem(selected);
                    if (manualDeviceList.getItemCount() == 0) {
                        manualDeviceList.setVisible(false);
                    }
                    deviceList.removeItem(selected);
                    deviceList.invalidate();
                    manualServers.remove(selected);
                    storeProperties();
                }
            });
            devicePanel.add(removeButton);
            fieldPanel.add(devicePanel);
            int result = JOptionPane.showConfirmDialog(FlingFrame.this, myPanel,
                    resourceBundle.getString("settings.title"), JOptionPane.OK_CANCEL_OPTION);
            if (result == JOptionPane.OK_OPTION) {
                transcodingParameterValues = transcodingParameters.getText();
                transcodingExtensionValues = transcodingExtensions.getText();
                storeProperties();
            }
        }
    });
    settingsButton.setToolTipText(resourceBundle.getString("settings.title"));
    devicePane.add(settingsButton);
    listPane.add(devicePane);

    // TODO
    volume = new JSlider(JSlider.VERTICAL, 0, 100, 0);
    volume.setUI(new MySliderUI(volume));
    volume.setMajorTickSpacing(25);
    // volume.setMinorTickSpacing(5);
    volume.setPaintTicks(true);
    volume.setEnabled(true);
    volume.setValue(100);
    volume.setToolTipText(resourceBundle.getString("volume.title"));
    volume.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int position = (int) source.getValue();
                rampClient.volume(position / 100.0f);
            }
        }

    });
    JPanel centerPanel = new JPanel(new BorderLayout());
    // centerPanel.add(volume, BorderLayout.WEST);

    centerPanel.add(DragHereIcon.makeUI(this), BorderLayout.CENTER);
    listPane.add(centerPanel);

    scrubber = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
    scrubber.addChangeListener(this);
    scrubber.setMajorTickSpacing(25);
    scrubber.setMinorTickSpacing(5);
    scrubber.setPaintTicks(true);
    scrubber.setEnabled(false);
    listPane.add(scrubber);

    // panel of playback buttons
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    label = new JLabel("00:00:00");
    buttonPane.add(label);
    url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/play.png");
    icon = new ImageIcon(url, resourceBundle.getString("button.play"));
    playButton = new JButton(icon);
    playButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            rampClient.play();
        }
    });
    buttonPane.add(playButton);
    url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/pause.png");
    icon = new ImageIcon(url, resourceBundle.getString("button.pause"));
    pauseButton = new JButton(icon);
    pauseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            rampClient.pause();
        }
    });
    buttonPane.add(pauseButton);
    url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/stop.png");
    icon = new ImageIcon(url, resourceBundle.getString("button.stop"));
    stopButton = new JButton(icon);
    stopButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            rampClient.stop();
            setDuration(0);
            scrubber.setValue(0);
            scrubber.setEnabled(false);
        }
    });
    buttonPane.add(stopButton);
    listPane.add(buttonPane);
    getContentPane().add(listPane);

    createProgressDialog();
    startWebserver();
    discoverDevices();
}

From source file:ca.phon.app.project.ProjectWindow.java

private MultiActionButton createCorpusButton() {
    MultiActionButton retVal = new MultiActionButton();

    ImageIcon newIcn = IconManager.getInstance().getIcon("places/folder", IconSize.SMALL);

    String s1 = "Corpus";
    String s2 = "Enter corpus name and press enter.  Press escape to cancel.";

    retVal.getTopLabel().setText(WorkspaceTextStyler.toHeaderText(s1));
    retVal.getTopLabel().setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    retVal.getTopLabel().setFont(FontPreferences.getTitleFont());
    retVal.getTopLabel().setIcon(newIcn);
    retVal.setAlwaysDisplayActions(true);

    retVal.setOpaque(false);// ww w  .  java2  s  .com

    ImageIcon cancelIcn = IconManager.getInstance().getIcon("actions/button_cancel", IconSize.SMALL);
    ImageIcon cancelIcnL = cancelIcn;

    PhonUIAction btnSwapAct = new PhonUIAction(this, "onSwapNewAndCreateCorpus", retVal);
    btnSwapAct.putValue(Action.ACTION_COMMAND_KEY, "CANCEL_CREATE_ITEM");
    btnSwapAct.putValue(Action.NAME, "Cancel create");
    btnSwapAct.putValue(Action.SHORT_DESCRIPTION, "Cancel create");
    btnSwapAct.putValue(Action.SMALL_ICON, cancelIcn);
    btnSwapAct.putValue(Action.LARGE_ICON_KEY, cancelIcnL);
    retVal.addAction(btnSwapAct);

    JPanel corpusNamePanel = new JPanel(new BorderLayout());
    corpusNamePanel.setOpaque(false);

    final JTextField corpusNameField = new JTextField();
    corpusNameField.setDocument(new NameDocument());
    corpusNameField.setText("Corpus Name");
    corpusNamePanel.add(corpusNameField, BorderLayout.CENTER);

    ActionMap actionMap = retVal.getActionMap();
    actionMap.put(btnSwapAct.getValue(Action.ACTION_COMMAND_KEY), btnSwapAct);
    InputMap inputMap = retVal.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);

    inputMap.put(ks, btnSwapAct.getValue(Action.ACTION_COMMAND_KEY));

    retVal.setActionMap(actionMap);
    retVal.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);

    PhonUIAction createNewCorpusAct = new PhonUIAction(this, "onCreateCorpus", corpusNameField);
    createNewCorpusAct.putValue(Action.SHORT_DESCRIPTION, "Create new corpus folder");
    createNewCorpusAct.putValue(Action.SMALL_ICON,
            IconManager.getInstance().getIcon("actions/list-add", IconSize.SMALL));

    JButton createBtn = new JButton(createNewCorpusAct);
    corpusNamePanel.add(createBtn, BorderLayout.EAST);

    corpusNameField.setAction(createNewCorpusAct);

    // swap bottom component in new project button
    retVal.setBottomLabelText(WorkspaceTextStyler.toDescText(s2));
    retVal.add(corpusNamePanel, BorderLayout.CENTER);

    retVal.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
        }

        @Override
        public void focusGained(FocusEvent e) {
            corpusNameField.requestFocus();
        }
    });

    return retVal;
}

From source file:ca.phon.app.project.ProjectWindow.java

private MultiActionButton createSessionButton() {
    MultiActionButton retVal = new MultiActionButton();

    ImageIcon newIcn = IconManager.getInstance().getIcon("mimetypes/text-xml", IconSize.SMALL);

    String s1 = "Session";
    String s2 = "Enter session name and press enter.  Press escape to cancel.";

    retVal.getTopLabel().setText(WorkspaceTextStyler.toHeaderText(s1));
    retVal.getTopLabel().setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    retVal.getTopLabel().setFont(FontPreferences.getTitleFont());
    retVal.getTopLabel().setIcon(newIcn);
    retVal.setAlwaysDisplayActions(true);

    retVal.setOpaque(false);/*from  w  w w .j  a v  a  2s . com*/

    ImageIcon cancelIcn = IconManager.getInstance().getIcon("actions/button_cancel", IconSize.SMALL);
    ImageIcon cancelIcnL = cancelIcn;

    PhonUIAction btnSwapAct = new PhonUIAction(this, "onSwapNewAndCreateSession", retVal);
    btnSwapAct.putValue(Action.ACTION_COMMAND_KEY, "CANCEL_CREATE_ITEM");
    btnSwapAct.putValue(Action.NAME, "Cancel create");
    btnSwapAct.putValue(Action.SHORT_DESCRIPTION, "Cancel create");
    btnSwapAct.putValue(Action.SMALL_ICON, cancelIcn);
    btnSwapAct.putValue(Action.LARGE_ICON_KEY, cancelIcnL);
    retVal.addAction(btnSwapAct);

    JPanel sessionNamePanel = new JPanel(new BorderLayout());
    sessionNamePanel.setOpaque(false);

    final JTextField sessionNameField = new JTextField();
    sessionNameField.setDocument(new NameDocument());
    sessionNameField.setText("Session Name");
    sessionNamePanel.add(sessionNameField, BorderLayout.CENTER);

    ActionMap actionMap = retVal.getActionMap();
    actionMap.put(btnSwapAct.getValue(Action.ACTION_COMMAND_KEY), btnSwapAct);
    InputMap inputMap = retVal.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);

    inputMap.put(ks, btnSwapAct.getValue(Action.ACTION_COMMAND_KEY));

    retVal.setActionMap(actionMap);
    retVal.setInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);

    PhonUIAction createNewSessionAct = new PhonUIAction(this, "onCreateSession", sessionNameField);
    createNewSessionAct.putValue(Action.SHORT_DESCRIPTION, "Create new session in selected corpus");
    createNewSessionAct.putValue(Action.SMALL_ICON,
            IconManager.getInstance().getIcon("actions/list-add", IconSize.SMALL));

    JButton createBtn = new JButton(createNewSessionAct);
    sessionNamePanel.add(createBtn, BorderLayout.EAST);

    sessionNameField.setAction(createNewSessionAct);

    // swap bottom component in new project button
    retVal.setBottomLabelText(WorkspaceTextStyler.toDescText(s2));
    retVal.add(sessionNamePanel, BorderLayout.CENTER);

    retVal.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {

        }

        @Override
        public void focusGained(FocusEvent e) {
            sessionNameField.requestFocus();
        }
    });

    return retVal;
}

From source file:fr.free.hd.servers.gui.PhonemView.java

@Override
protected JComponent createControl() {
    final JPanel view = new JPanel(new BorderLayout());

    Collection<Phonem> phonesList = phonemsDAO.getPhonems();
    Map<String, Phonem> mapList = new HashMap<String, Phonem>();
    for (Phonem phonem : phonesList) {
        mapList.put(phonem.getPhonem(), phonem);
    }//from  w  w w.  j a v  a  2 s.  c o m

    final StatementListModel model = new StatementListModel(mapList);

    printCommand.setModel(model);
    printCommand.setFace(face);
    copyCommand.setModel(model);
    copyCommand.setFace(face);

    list = new JList(model);
    final JScrollPane sp = new JScrollPane(list);
    final JTextField field = new JTextField();
    field.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void changedUpdate(DocumentEvent e) {
            model.setString(field.getText());
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            model.setString(field.getText());
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            model.setString(field.getText());
        }

    });

    final PhonemListModel phonemModel = new PhonemListModel((List<Phonem>) phonesList);
    final JList phonemList = new JList(phonemModel);
    final JScrollPane spPhonemList = new JScrollPane(phonemList);
    phonemList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        // private int oldIndex = -1;
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                Phonem innerPhonem = (Phonem) phonemModel.getElementAt(phonemList.getSelectedIndex());
                field.setText(field.getText() + innerPhonem.getPhonem());
            }
        }
    });
    phonemList.setCellRenderer(new PhonemListRenderer());
    list.setCellRenderer(new StatementPhonemListRenderer(face));
    list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    list.setVisibleRowCount(1);

    view.add(spPhonemList, BorderLayout.WEST);
    view.add(sp, BorderLayout.CENTER);
    view.add(field, BorderLayout.SOUTH);

    field.requestFocus();

    return view;
}

From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.GUIComponents.FLIMPanel.java

private void updateDelayField(JTextField field) {
    int num = 0;/*from w w w .  j a v a  2s  .c  om*/
    int min = 0;
    int max = 16666;
    int inc = 25;

    try {
        max = Integer.parseInt(core_.getProperty("Laser", "Frequency"));
    } catch (Exception e) {
    }

    if (!field.getText().isEmpty()) {
        num = Integer.parseInt(field.getText());
        if (num > max)
            num = max;
        else if (num < min)
            num = min;
        num = round(num / inc) * inc;
    } else {
        num = min;
    }
    field.setText(String.valueOf(num));
}

From source file:edu.ku.brc.af.auth.UserAndMasterPasswordMgr.java

/**
 * @return/*from   ww w . j  a v  a 2s. c o  m*/
 */
protected String[] getUserNamePasswordKey() {
    loadAndPushResourceBundle("masterusrpwd");

    FormLayout layout = new FormLayout("p, 4dlu, p, 8px, p", "p, 2dlu, p, 2dlu, p, 16px, p, 2dlu, p, 2dlu, p");
    layout.setRowGroups(new int[][] { { 1, 3, 5 } });

    PanelBuilder pb = new PanelBuilder(layout);

    final JTextField dbUsrTxt = createTextField(30);
    final JPasswordField dbPwdTxt = createPasswordField(30);
    final JTextField usrText = createTextField(30);
    final JPasswordField pwdText = createPasswordField(30);
    final char echoChar = pwdText.getEchoChar();

    final JLabel dbUsrLbl = createI18NFormLabel("USERNAME", SwingConstants.RIGHT);
    final JLabel dbPwdLbl = createI18NFormLabel("PASSWORD", SwingConstants.RIGHT);
    final JLabel usrLbl = createI18NFormLabel("USERNAME", SwingConstants.RIGHT);
    final JLabel pwdLbl = createI18NFormLabel("PASSWORD", SwingConstants.RIGHT);

    usrText.setText(usersUserName);

    CellConstraints cc = new CellConstraints();

    int y = 1;
    pb.addSeparator(UIRegistry.getResourceString("MASTER_SEP"), cc.xyw(1, y, 5));
    y += 2;

    pb.add(dbUsrLbl, cc.xy(1, y));
    pb.add(dbUsrTxt, cc.xy(3, y));
    y += 2;

    pb.add(dbPwdLbl, cc.xy(1, y));
    pb.add(dbPwdTxt, cc.xy(3, y));
    y += 2;

    pb.addSeparator(UIRegistry.getResourceString("USER_SEP"), cc.xyw(1, y, 5));
    y += 2;

    pb.add(usrLbl, cc.xy(1, y));
    pb.add(usrText, cc.xy(3, y));
    y += 2;

    pb.add(pwdLbl, cc.xy(1, y));
    pb.add(pwdText, cc.xy(3, y));

    pb.setDefaultDialogBorder();

    final CustomDialog dlg = new CustomDialog((Frame) null, getResourceString("MASTER_INFO_TITLE"), true,
            CustomDialog.OKCANCELAPPLYHELP, pb.getPanel());
    dlg.setOkLabel(getResourceString("GENERATE_KEY"));
    dlg.setHelpContext("MASTERPWD_GEN");
    dlg.setApplyLabel(showPwdLabel);

    dlg.createUI();
    dlg.getOkBtn().setEnabled(false);

    popResourceBundle();

    DocumentListener docListener = new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent e) {
            String dbUserStr = dbUsrTxt.getText();

            boolean enable = !dbUserStr.isEmpty() && !((JTextField) dbPwdTxt).getText().isEmpty()
                    && !usrText.getText().isEmpty() && !((JTextField) pwdText).getText().isEmpty();
            if (enable && isNotEmpty(dbUserStr) && dbUserStr.equalsIgnoreCase("root")) {
                loadAndPushResourceBundle("masterusrpwd");
                UIRegistry.showLocalizedError("MASTER_NO_ROOT");
                popResourceBundle();
                enable = false;
            }
            dlg.getOkBtn().setEnabled(enable);
        }
    };

    dbUsrTxt.getDocument().addDocumentListener(docListener);
    dbPwdTxt.getDocument().addDocumentListener(docListener);
    usrText.getDocument().addDocumentListener(docListener);
    pwdText.getDocument().addDocumentListener(docListener);

    currEcho = echoChar;

    dlg.getApplyBtn().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dlg.getApplyBtn().setText(currEcho == echoChar ? hidePwdLabel : showPwdLabel);
            currEcho = currEcho == echoChar ? 0 : echoChar;
            pwdText.setEchoChar(currEcho);
            dbPwdTxt.setEchoChar(currEcho);
        }
    });

    dlg.setVisible(true);
    if (!dlg.isCancelled()) {
        return new String[] { dbUsrTxt.getText(), ((JTextField) dbPwdTxt).getText(), usrText.getText(),
                ((JTextField) pwdText).getText() };
    }

    return null;
}

From source file:krasa.formatter.plugin.ProjectSettingsForm.java

private void browseForFile(@NotNull final JTextField target) {
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
    descriptor.setHideIgnored(false);/*  ww  w  . ja  v a  2  s  . com*/

    descriptor.setTitle("Select config file");
    String text = target.getText();
    final VirtualFile toSelect = text == null || text.isEmpty() ? getProject().getBaseDir()
            : LocalFileSystem.getInstance().findFileByPath(text);

    // 10.5 does not have #chooseFile
    VirtualFile[] virtualFile = FileChooser.chooseFiles(descriptor, getProject(), toSelect);
    if (virtualFile != null && virtualFile.length > 0) {
        target.setText(virtualFile[0].getPath());
    }
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JPanel buildPanelFilter(final String topLabel, final int textfieldSize, final Dimension dimension,
        final JList list, final boolean left) {
    JPanel left_filtro = new JPanel(new GridBagLayout());
    left_filtro.setPreferredSize(dimension);
    left_filtro.setOpaque(false);//from  w w w  .ja  va  2  s .co  m
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    left_filtro.add(new JLabel(topLabel, JLabel.LEFT), gbc);

    final JTextField filtro = new JTextField(textfieldSize);
    gbc.gridy++;
    left_filtro.add(filtro, gbc);

    AbstractAction actionStartFilter = new AbstractAction(null, getIcon("Buttons.noFiltrar")) {

        private static final long serialVersionUID = -4737487889360372801L;

        @Override
        public void actionPerformed(ActionEvent e) {
            ((DefaultListModel) list.getModel()).removeAllElements();
            filtro.setText(null);
            if (left) {
                for (Object obj : leftItems) {
                    ((DefaultListModel) list.getModel()).addElement(obj);
                }
            } else {
                for (Object obj : rightItems) {
                    ((DefaultListModel) list.getModel()).addElement(obj);
                }
            }

        }
    };
    AbstractAction actionStopFilter = new AbstractAction(null, getIcon("Buttons.filtrar")) {

        private static final long serialVersionUID = 6570608476764008290L;

        @Override
        public void actionPerformed(ActionEvent e) {
            ((DefaultListModel) list.getModel()).removeAllElements();
            if (left) {
                for (Object obj : leftItems) {
                    if (compare(filtro, obj)) {
                        ((DefaultListModel) list.getModel()).addElement(obj);
                    }
                }
            } else {
                for (Object obj : rightItems) {
                    if (compare(filtro, obj)) {
                        ((DefaultListModel) list.getModel()).addElement(obj);
                    }
                }
            }
        }

        private boolean compare(final JTextField filtro, Object obj) {
            final String elemento = obj.toString().toUpperCase().trim();
            final String text = filtro.getText().toUpperCase().trim();

            final String pattern = text.replace("*", ".*");
            boolean res = Pattern.matches(pattern, elemento);

            return res;// || elemento.indexOf(text) >= 0;
        }
    };
    JButton jButton = new JButton(actionStartFilter);
    JButton jButton2 = new JButton(actionStopFilter);
    jButton.setBorderPainted(false);
    jButton2.setBorderPainted(false);
    jButton.setContentAreaFilled(false);
    jButton2.setContentAreaFilled(false);
    jButton.setPreferredSize(
            new Dimension(jButton.getIcon().getIconWidth(), jButton.getIcon().getIconHeight()));
    jButton2.setPreferredSize(
            new Dimension(jButton2.getIcon().getIconWidth(), jButton2.getIcon().getIconHeight()));

    gbc.gridx++;
    left_filtro.add(jButton2, gbc);
    gbc.gridx++;
    left_filtro.add(jButton, gbc);
    return left_filtro;
}