本文整理汇总了Java中javax.swing.JTable.putClientProperty方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.putClientProperty方法的具体用法?Java JTable.putClientProperty怎么用?Java JTable.putClientProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.putClientProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableCellEditorComponent
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* It sets the cursot at the beginnig of edited cell, in case of searching it highlights the found text.
* At the end it request for focus so the editor component (JTextField) has it, not the table.
* This is also a hack with reason to figure out which cell is going to be edited, if a key or a value.
*/
@Override
public Component getTableCellEditorComponent(JTable table,
Object value, boolean isSelected, int row, int column) {
// Key or value? Only in the first column are keys.
isKeyCell = (column == 0) ? true : false;
valueComponent.getDocument().removeDocumentListener(listener);
commentComponent.getDocument().removeDocumentListener(listener);
final JTextField textField = (JTextField)super.getTableCellEditorComponent(table, value, isSelected, row, column);
valueComponent.getDocument().addDocumentListener(listener);
commentComponent.getDocument().addDocumentListener(listener);
Caret caret = textField.getCaret();
caret.setVisible(true);
caret.setDot(0);
textField.setFont(settings.getFont());
// Check for search results.
// If search was performed, highlight the found string.
int[] result = (int[])table.getClientProperty(FindPerformer.TABLE_SEARCH_RESULT);
if(result != null && row == result[0] && column == result[1]) {
table.putClientProperty(FindPerformer.TABLE_SEARCH_RESULT, null); // removes property
caret.setDot(result[2]);
caret.moveDot(result[3]);
}
return textField;
}