Example usage for javax.swing JTextField getClientProperty

List of usage examples for javax.swing JTextField getClientProperty

Introduction

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

Prototype

public final Object getClientProperty(Object key) 

Source Link

Document

Returns the value of the property with the specified key.

Usage

From source file:org.eclim.installer.step.VimStep.java

/**
 * {@inheritDoc}/* ww  w.  j a va 2 s. c  o m*/
 * @see org.formic.wizard.step.GuiStep#init()
 */
public Component init() {
    GuiForm form = createForm();

    String files = fieldName("files");
    fileChooser = new FileChooser(JFileChooser.DIRECTORIES_ONLY);

    // allow just .vim dirs to not be hidden
    fileChooser.getFileChooser().setFileHidingEnabled(false);
    fileChooser.getFileChooser().addChoosableFileFilter(new FileFilter() {
        public boolean accept(java.io.File f) {
            String path = f.getAbsolutePath();
            return f.isDirectory() && (path.matches(".*/\\.vim(/.*|$)") || !path.matches(".*/\\..*"));
        }

        public String getDescription() {
            return null;
        }
    });

    String skip = fieldName("skip");
    skipCheckBox = new JCheckBox(Installer.getString(skip));
    skipCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean selected = ((JCheckBox) e.getSource()).isSelected();
            JTextField fileField = fileChooser.getTextField();
            fileField.setEnabled(!selected);
            fileChooser.getButton().setEnabled(!selected);

            if (dirList != null) {
                dirList.setEnabled(!selected);
            }

            // hacky
            Validator validator = (Validator) fileField.getClientProperty("validator");
            setValid(selected || validator.isValid(fileField.getText()));
        }
    });

    panel = new JPanel(new MigLayout("wrap 2", "[fill]", "[] [] [] [fill, grow]"));
    panel.add(form.createMessagePanel(), "span");
    panel.add(new JLabel(Installer.getString(files)), "split");
    panel.add(fileChooser, "skip");
    panel.add(skipCheckBox, "span");

    form.bind(files, fileChooser.getTextField(),
            new ValidatorBuilder().required().isDirectory().fileExists().isWritable().validator());

    return panel;
}