- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
JTextField.setEnabled()
和 JTextField.setEditable()
有什么区别?在我的代码中,我有一个继承自 JTextField
的类的实例。但是当我设置它的属性 setEnabled(false)
时,我仍然可以在我的程序中编辑和处理它的内容。但是,当我设置其属性 setEditable(false)
时,我无法再编辑其文本。如果是这样的话。那么这里的setEnabled()
属性的作用是什么?
我的继承类代码是:
private static class CCField extends JTextField{
private static final long serialVersionUID = 1L;
public CCField() {
this( DEFAULT_COLUMN_COUNT );
}
public CCField(final int cols) {
super( cols );
}
添加信息当我调用此类的 setEnabled()
属性时,它不会对文本字段产生任何影响,它仍然保持启用状态。我的代码中有一个容器 Jcomponent
,它有一个 CCField
作为子组件。因此,当我尝试使用 setEnabled(false)
禁用它时,它仍然可以编辑。而当我尝试使用 setEditable(false)
禁用它时,它被禁用了。这就是我在容器中访问此 textField 的方式:
JComponent jComp = DDEUtil.getComponent(icTableLayout,icDS);
((JTextField)jComp.getComponent(1)).setEditable(false);
DDEUtil.getComponent
中发生的事情太复杂了,因为它涉及许多类,无法在此处发布。
我想知道我没有覆盖此组件的任何方法,那么为什么它会显示此行为。
最佳答案
在我的例子中,setEditable(false)
使字段变灰,而 setEnabled(false)
没有使字段变灰。
TextField are editable by default. The code setEditable(false) makes the TextField uneditable. It is still selectable and the user can copy data from it, but the user cannot change the TextField's contents directly.
The code setEnabled(false), disables this TextField. It is not selectable and the user can not copy data from it and the user cannot change the TextField's contents directly.
有用的链接
关于java - JTextField setEnabled 与 setEditable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21695175/
如果我想将 tableView 置于编辑模式。这样做的正确做法是什么?我似乎可以通过调用 [super setEditing:YES animated:YES] 将 tableView 置于编辑模式是
我想创建此代码:用户输入一个数值,如果输入字符则会抛出异常该字段将停止工作,然后出现另一个框架并显示错误消息用户关闭新框架后,一切恢复原样这意味着该领域将再次发挥作用!我设法使该字段停止工作,但我不知
在我的 UIViewController 中,我有一个 UITableView,它包含不同的单元格,其中包含使用 NSUserDefaults 保存的内容。我还有一个自定义 UIBarButtonIt
我正在开发传统的 iPhone UINavigationController 应用程序,带有自动后退按钮等。 我正在研究按下“编辑”按钮时的情况。左侧后退图标变暗,我的新图标出现,然后一旦我再次点击“
我想重新排列我的表格 View 中的行。我已经实现了这两个方法。 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIn
我试图通过向右移动标签为红色删除图标创建空间来为自定义 UITableViewCell 的内容设置动画。移动工作正常,但整个文本被截断,这是不应该的,我没有理由这样做,因为有足够的空间。这是编辑状态下
我无法让我的 UITableView 退出编辑模式。这是我进入和退出编辑模式的方式,请参阅下面的链接以获取源代码- 进入编辑模式 DbgTableViewHandler.swift(126):
我使用下面的代码显示使表格变得可编辑,但表格 View 似乎没有在左侧显示删除按钮。为什么? - (void)viewListEditale:(NSNotification *)notific
因此,我在 tableview 中有一个自定义 tableview 单元格,当我使用 [self.tableView setEditing:YES animated:YES]; 代码设置编辑模式时。
我有一个UITableViewCell的子类,添加了UITextField,可以在编辑模式下编辑单元格的内容。 在我的自定义单元实现中,我像这样覆盖了setEditing: -(void)setEdi
我想为表格 View 中的各个单元格添加插入和删除按钮。 以下代码对于删除插入效果很好,我也希望按钮不在导航中。 - (void)viewDidLoad { [super viewDidLoa
我目前已经为我的 TableView 实现了 setEditing/commitEditing 方法,它现在在滑动单元格时显示“删除”按钮。 只是想知道是否有任何方法可以将此按钮上的文本从“删除”更改
我有一个任务是在他出现的时候(比如WhatsApp)立刻显示联系人编辑界面,我用下面的方式显示给他。 @objc private func presentContactEditControlle
选择编辑模式时,我正在使用编辑/完成按钮将MKMapView向上移动,以便在屏幕底部的ImageView中显示消息。我的理解是改变这个按钮的功能我必须使用 override func setEditi
我正在尝试启用拖放 UITableViewCell 来交换它们。这不是问题,但我想在没有“setEditing:”方法的情况下进行。我想在用户使用 longGestureAction 之类的东西拖动单
我在viewDidLoad()下实现navigationItem.leftBarButtonItem = editButtonItem,据说要实现setEditing(_ editing: Bool,
我有一个包含超链接的 JTextPane。当它可编辑时,超链接不可点击,并且光标悬停在它们上时(例如到手)不会改变状态。当它不可编辑时,超链接是可点击的,并且光标悬停在它们上面时会改变状态。完美的。
JTextField.setEnabled() 和 JTextField.setEditable() 有什么区别?在我的代码中,我有一个继承自 JTextField 的类的实例。但是当我设置它的属性
我知道,当我实现 tableView:willBeginEditingRowAtIndexPath: 和 tableView:didEndEditingRowAtIndexPath: 时,滑动删除不会
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve th
我是一名优秀的程序员,十分优秀!