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


Java JXTable.prepareRenderer方法代碼示例

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


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

示例1: interactiveCheckBoxRendererOpacity1513

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
     * Issue #1513-swingx: opacity of JRendererCheckBox can't be effected by 
     * client code.
     * 
     * Here's a use-case: make all components in the stack not-opaque to show
     * a background image. (note: opacity not false for number column)
     */
    public void interactiveCheckBoxRendererOpacity1513() {
        JXPanel panel = new JXPanel(new BorderLayout());
        panel.setBackgroundPainter(new ImagePainter(XTestUtils.loadDefaultImage("moon.jpg")));
        JXTable table = new JXTable(new AncientSwingTeam());
        table.addHighlighter(HighlighterFactory.createSimpleStriping());
        table.addHighlighter(new PainterHighlighter(HighlightPredicate.ROLLOVER_ROW, 
                new MattePainter(PaintUtils.setAlpha(Color.RED, 100))));
//                new BusyPainter()));
        panel.add(new JScrollPane(table));
        table.setOpaque(false);
        JComponent comp = (JComponent) table.prepareRenderer(0, 0);
        comp.setOpaque(false);
        AbstractButton checkBox = (AbstractButton) table.prepareRenderer(0, AncientSwingTeam.BOOLEAN_COLUMN);
        checkBox.setOpaque(false);
        ((JComponent) table.getParent()).setOpaque(false);
        ((JComponent) table.getParent().getParent()).setOpaque(false);
        showInFrame(panel, "Checkbox: set to opacity");
    }
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:26,代碼來源:RendererVisualCheck.java

示例2: testUpdateRendererOnLFChange

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * test if renderer properties are updated on LF change. <p>
 * Note: this can be done examplary only. Here: we use the 
 * font of a rendererComponent returned by a HyperlinkProvider for
 * comparison. There's nothing to test if the font are equal
 * in System and crossplattform LF. <p>
 * 
 * There are spurious problems when toggling UI (since when?) 
 * with LinkRenderer
 * "no ComponentUI class for: org.jdesktop.swingx.LinkRenderer$1"
 * that's the inner class JXHyperlink which overrides updateUI.
 * 
 * PENDING: this was moved from tableUnitTest - had been passing with
 * LinkRenderer but with HyperlinkProvider
 * now is failing (on server with defaultToSystem == false, locally win os 
 * with true), probably due to slightly different setup now 
 * in renderer defaultVisuals? It resets the font to table's which
 * LinkRenderer didn't. Think whether to change the provider go back
 * to hyperlink font? 
 */
public void testUpdateRendererOnLFChange() {
    boolean defaultToSystemLF = true;
    setSystemLF(defaultToSystemLF);
    TableCellRenderer comparison = new DefaultTableRenderer(new HyperlinkProvider());
    TableCellRenderer linkRenderer = new DefaultTableRenderer(new HyperlinkProvider());
    JXTable table = new JXTable(2, 3);
    Component comparisonComponent = comparison.getTableCellRendererComponent(table, null, false, false, 0, 0);
    Font comparisonFont = comparisonComponent.getFont();
    table.getColumnModel().getColumn(0).setCellRenderer(linkRenderer);
    setSystemLF(!defaultToSystemLF);
    SwingUtilities.updateComponentTreeUI(comparisonComponent);
    if (comparisonFont.equals(comparisonComponent.getFont())) {
        LOG.info("cannot run test - equal font " + comparisonFont);
        return;
    }
    SwingUtilities.updateComponentTreeUI(table);
    Component rendererComp = table.prepareRenderer(table.getCellRenderer(0, 0), 0, 0);
    assertEquals("renderer font must be updated", 
            comparisonComponent.getFont(), rendererComp.getFont());
    
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:42,代碼來源:RendererIssues.java

示例3: testHyperlinkProviderForeground

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Issue #840-swingx: hyperlink foreground unreadable for dark selection colors.
 * 
 * Test that selected foreground is same as table. 
 * 
 */
@Test
public void testHyperlinkProviderForeground() {
    JXTable table = new JXTable(20, 2);
    HyperlinkProvider provider = new HyperlinkProvider();
    JXHyperlink hyperlink = provider.getRendererComponent(null);
    Color unclicked = hyperlink.getUnclickedColor();
    table.setDefaultRenderer(Object.class, new DefaultTableRenderer(provider));
    table.prepareRenderer(table.getCellRenderer(0, 0), 0, 0);
    assertEquals("hyperlink foreground set to unclicked", unclicked, hyperlink.getForeground());
    table.setRowSelectionInterval(0, 0);
    // JW: had been failing before because I forgot to re-prepare :-)
    table.prepareRenderer(table.getCellRenderer(0, 0), 0, 0);
    assertEquals("hyperlink foreground set to table's selection foreground", 
            table.getSelectionForeground(), hyperlink.getForeground());
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:22,代碼來源:RenderingTest.java

示例4: testTableIncrementalHighlighter

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/** 
 * Test SearchHighlight used in incremental search of JXTable.  
 *
 */
@Test
public void testTableIncrementalHighlighter() {
    JXTable table = new JXTable(new TestTableModel());
    table.putClientProperty(AbstractSearchable.MATCH_HIGHLIGHTER, Boolean.TRUE);
    int row = 3;
    int column = 1;
    String firstSearchText = "wo" + row;
    PatternModel model = new PatternModel();
    model.setRawText(firstSearchText);
    // make sure we had a match
    int foundIndex = table.getSearchable().search(model.getPattern(), -1);
    assertEquals("must return be found", row, foundIndex);
    Component comp = table.prepareRenderer(table.getCellRenderer(row, column), row, column);
    assertEquals(Color.YELLOW.brighter(), comp.getBackground());
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:20,代碼來源:FindTest.java

示例5: updateRowHeight

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Sets per-row rowHeight based on the rendering component's preferred height.
 * 
 * @param table
 */
private void updateRowHeight(final JXTable table) {
    for (int row = 0; row < table.getRowCount(); row++) {
        int rowHeight = 0;
        for (int column = 0; column < table.getColumnCount(); column++) {
            Component comp = table.prepareRenderer(table
                    .getCellRenderer(row, column), row, column);
            rowHeight = Math.max(rowHeight,
                    comp.getPreferredSize().height);
        }
        table.setRowHeight(row, rowHeight); 
    }
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:18,代碼來源:RendererVisualCheck.java

示例6: 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

示例7: 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

示例8: testTableUnSelectedDoNothingHighlighter

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Issue #258-swingx: DefaultTableCellRenderer has memory. 
 * How to formulate as test?
 * this is testing the hack (reset the memory in ResetDTCR to null), not
 * any highlighter!
 */
public void testTableUnSelectedDoNothingHighlighter() {
    JXTable table = new JXTable(10, 2);
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setForeground(foreground);
    table.setHighlighters(new ColorHighlighter());
    Component comp = table.prepareRenderer(renderer, 0, 0);
    assertEquals("do nothing highlighter must not change foreground", foreground, comp.getForeground());
    fail("testing the hack around DefaultTableCellRenderer memory - not the memory itself");
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:16,代碼來源:HighlighterIssues.java


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