本文整理汇总了Java中javax.swing.text.JTextComponent.setFocusable方法的典型用法代码示例。如果您正苦于以下问题:Java JTextComponent.setFocusable方法的具体用法?Java JTextComponent.setFocusable怎么用?Java JTextComponent.setFocusable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.JTextComponent
的用法示例。
在下文中一共展示了JTextComponent.setFocusable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setEditedComponent
import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
void setEditedComponent(Component comp, String text) {
if (!comp.isShowing() || comp.getParent() == null)
throw new IllegalArgumentException();
editedComp = comp;
editedText = text;
if (inPlaceField != null) {
remove(inPlaceField);
inPlaceField = null;
}
if (comp instanceof JLabel || comp instanceof AbstractButton || comp instanceof JTabbedPane) {
layerEditing = true;
superContainer = null;
createInPlaceField();
}
else if (comp instanceof JTextField || comp instanceof JTextArea) {
layerEditing = false;
superContainer = comp.getParent();
Container cont = superContainer;
do {
if (cont.getParent() instanceof JLayeredPane) {
superContainer = cont;
break;
}
else cont = cont.getParent();
}
while (cont != null);
editingTextComp = (JTextComponent)editedComp;
oldText = editingTextComp.getText();
editingTextComp.setText(editedText);
// enable focus on component in component layer
editingTextComp.setFocusable(true);
if (!editingTextComp.isEnabled()) {
editingTextComp.setEnabled(true);
enabled = true;
}
if (!editingTextComp.isEditable()) {
editingTextComp.setEditable(true);
madeEditable = true;
}
}
else throw new IllegalArgumentException();
if (editingTextComp != null) {
FormUtils.setupTextUndoRedo(editingTextComp);
}
attachListeners();
}