Example usage for javax.swing.text JTextComponent setEnabled

List of usage examples for javax.swing.text JTextComponent setEnabled

Introduction

In this page you can find the example usage for javax.swing.text JTextComponent setEnabled.

Prototype

@BeanProperty(expert = true, preferred = true, visualUpdate = true, description = "The enabled state of the component.")
public void setEnabled(boolean enabled) 

Source Link

Document

Sets whether or not this component is enabled.

Usage

From source file:ch.zhaw.iamp.rct.ui.GrammarWindow.java

private boolean readFileOrShowError(String file, JTextComponent target) {
    File source = new File(file);
    if (source.exists()) {
        try {//from  w  w w.  j av  a 2s .  c  o  m
            target.setText(FileUtils.readFileToString(source));
            target.setEnabled(true);
            target.requestFocus();
            return true;
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "The file could not be read: " + ex.getLocalizedMessage(),
                    "Error", JOptionPane.ERROR_MESSAGE);
            target.setEnabled(false);
        }
    } else {
        target.setText("");
        target.setEnabled(true);
        target.requestFocus();
    }

    return false;
}