當前位置: 首頁>>代碼示例>>Java>>正文


Java JXTable.getCellRenderer方法代碼示例

本文整理匯總了Java中org.jdesktop.swingx.JXTable.getCellRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Java JXTable.getCellRenderer方法的具體用法?Java JXTable.getCellRenderer怎麽用?Java JXTable.getCellRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jdesktop.swingx.JXTable的用法示例。


在下文中一共展示了JXTable.getCellRenderer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCellRenderer

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Returns the cell renderer to use for measuring. Delegates to 
 * JXTable for visible columns, duplicates table logic for hidden
 * columns. <p>
 * 
 * @param table the table which provides the renderer
 * @param columnExt the TableColumn to configure
 * 
 * @return returns a cell renderer for measuring.
 */
protected TableCellRenderer getCellRenderer(JXTable table, TableColumnExt columnExt) {
    int viewIndex = table.convertColumnIndexToView(columnExt
            .getModelIndex());
    if (viewIndex >= 0) {
        // JW: ok to not guard against rowCount < 0?
        // technically, the index should be a valid coordinate
        return table.getCellRenderer(0, viewIndex);
    }
    // hidden column - need api on JXTable to access renderer for hidden?
    // here we duplicate JXTable api ... maybe by-passing the strategy
    // implemented there
    TableCellRenderer renderer = columnExt.getCellRenderer();
    if (renderer == null) {
        renderer = table.getDefaultRenderer(table.getModel().getColumnClass(columnExt.getModelIndex()));
    }
    return renderer;
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:28,代碼來源:ColumnFactory.java

示例2: testPackMargin

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Issue #266-swingx: support customization of pack margin.
 * 
 * added property to ColumnFactory. 
 *  
 */
@Test
public void testPackMargin() {
    final int special = 1;
    JXTable table = new JXTable(1, 2);
    ColumnFactory factory = new ColumnFactory();
    table.setColumnFactory(factory);
    table.setValueAt("something that's wider than 75", 0, special);
    TableColumnExt columnExt = table.getColumnExt(special);
    table.packAll();
    TableCellRenderer renderer = table.getCellRenderer(0, special);
    Component comp = table.prepareRenderer(renderer, 0, special);
    int realPrefWidth = 2 * factory.getDefaultPackMargin() // magic value - JXTable's default margin, 
                              //  needs to be made configurable, see Issue 266 
        + comp.getPreferredSize().width;
    // sanity - default margin kicks in
    assertEquals(realPrefWidth, columnExt.getPreferredWidth());
    
    int margin = 10;
    factory.setDefaultPackMargin(margin);
    table.packAll();
    table.prepareRenderer(renderer, 0, special);
    int otherPrefWidth = 2 * margin + comp.getPreferredSize().width;
    assertEquals(otherPrefWidth, columnExt.getPreferredWidth());
    
    
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:33,代碼來源:ColumnFactoryTest.java

示例3: testPatternPredicateAllColumns

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Issue #1317-swingx: PatternPredicate causes exception with testColumn -1 (ALL)
 * 
 */
@Test
public void testPatternPredicateAllColumns() {
    JXTable table = new JXTable(new AncientSwingTeam());
    PatternPredicate predicate = new PatternPredicate(".*e.*");
    table.addHighlighter(new ColorHighlighter(predicate, Color.BLUE, null));
    for (int i = 0; i < table.getRowCount(); i++) {
        for (int j = 0; j < table.getColumnCount(); j++) {
            TableCellRenderer renderer = table.getCellRenderer(i, j);
            table.prepareRenderer(renderer, i, j);
        }
    }
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:17,代碼來源:HighlightPredicateTest.java


注:本文中的org.jdesktop.swingx.JXTable.getCellRenderer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。