Java Code Examples for javax.swing.JTable#getClientProperty()

The following examples show how to use javax.swing.JTable#getClientProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertiesTableCellEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
* 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;
}