List of usage examples for javax.swing.text JTextComponent setEnabled
@BeanProperty(expert = true, preferred = true, visualUpdate = true, description = "The enabled state of the component.") public void setEnabled(boolean enabled)
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; }