当前位置: 首页>>代码示例>>Java>>正文


Java JTable.getClientProperty方法代码示例

本文整理汇总了Java中javax.swing.JTable.getClientProperty方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.getClientProperty方法的具体用法?Java JTable.getClientProperty怎么用?Java JTable.getClientProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTable的用法示例。


在下文中一共展示了JTable.getClientProperty方法的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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:PropertiesTableCellEditor.java


注:本文中的javax.swing.JTable.getClientProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。