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


Java JXTable.setHighlighters方法代碼示例

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


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

示例1: interactiveTableBorderHighlighter

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Show variants of border Highlighters.
 *
 */
public void interactiveTableBorderHighlighter() {
    JXTable table = new JXTable(tableModel);
    table.setVisibleRowCount(table.getRowCount());
    table.setVisibleColumnCount(7);
    table.packAll();
    table.setColumnControlVisible(true);
    
    BorderHighlighter outer = new BorderHighlighter(new HighlightPredicate.ColumnHighlightPredicate(1),
            BorderFactory.createLineBorder(Color.RED, 3));
    BorderHighlighter inner = new BorderHighlighter(new HighlightPredicate.ColumnHighlightPredicate(2),
            BorderFactory.createLineBorder(Color.RED, 3), true, true);
    BorderHighlighter replace = new BorderHighlighter(new HighlightPredicate.ColumnHighlightPredicate(0),
            BorderFactory.createLineBorder(Color.RED, 3), false, true);
    table.setHighlighters(outer, inner, replace);
    showWithScrollingInFrame(table, "Border Highlighters");
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:21,代碼來源:HighlighterClientVisualCheck.java

示例2: interactiveTablePatternHighlighterJP

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Multiple Highlighters (shown as example in Javapolis 2007).
 * 
 */
public void interactiveTablePatternHighlighterJP() {
    JXTable table = new JXTable(tableModel);
    table.setVisibleRowCount(table.getRowCount());
    table.setVisibleColumnCount(7);
    table.packAll();
    table.setColumnControlVisible(true);

    Font font = table.getFont().deriveFont(Font.BOLD | Font.ITALIC);
    Highlighter simpleStriping = HighlighterFactory.createSimpleStriping();
    PatternPredicate patternPredicate = new PatternPredicate("^M", 1);
    ColorHighlighter magenta = new ColorHighlighter(patternPredicate, null,
            Color.MAGENTA, null, Color.MAGENTA);
    FontHighlighter derivedFont = new FontHighlighter(patternPredicate,
            font);
    AbstractHighlighter gradient = createRelativeGradientHighlighter(HorizontalAlignment.LEFT, AncientSwingTeam.INTEGER_COLUMN);
    gradient.setHighlightPredicate(new HighlightPredicate.ColumnHighlightPredicate(AncientSwingTeam.INTEGER_COLUMN));
    
    LOG.info("" + (table.getValueAt(0, 3) instanceof Number));
    Highlighter shading = new ShadingColorHighlighter(
            new HighlightPredicate.ColumnHighlightPredicate(1));

    table.setHighlighters(simpleStriping, magenta, derivedFont, shading //);
            , gradient);
    showWithScrollingInFrame(table, "Multiple Highlighters");
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:30,代碼來源:HighlighterClientVisualCheck.java

示例3: interactiveTableRollover

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
public void interactiveTableRollover() {
    JXTable table = new JXTable(sortableTableModel);
    final CompoundHighlighter compoundHighlighter = new CompoundHighlighter(foregroundHighlighter);
    table.setHighlighters(compoundHighlighter);
    JXFrame frame = wrapWithScrollingInFrame(table, "Table with rollover");
    Action toggleAction = new AbstractAction("toggle foreground/background") {
        boolean isBackground;
        public void actionPerformed(ActionEvent e) {
            if (isBackground) {
                compoundHighlighter.addHighlighter(foregroundHighlighter);
                compoundHighlighter.removeHighlighter(backgroundHighlighter);
            } else {
                compoundHighlighter.addHighlighter(backgroundHighlighter);
                compoundHighlighter.removeHighlighter(foregroundHighlighter);
                
            }
            isBackground = !isBackground;
            
        }
        
    };
    addAction(frame, toggleAction);
    frame.setVisible(true);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:25,代碼來源:RolloverVisualCheck.java

示例4: interactiveBorderHighlighterOnRollover

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
     * Issue #1295-swingx: JXTable rolloverController repaint incomplete.
     * Column not repainted.
     */
    public void interactiveBorderHighlighterOnRollover() {
        JXTable table = new JXTable(tableModel) {
            int count;
            @Override
            protected void paintComponent(Graphics g) {
                // crude check if the logic of column/row painting
                // in TableRolloverController is working (looks so)
//                LOG.info("paint clip: " + count++ + g.getClip());
                super.paintComponent(g);
            }
            
        };
        final AbstractHighlighter hlRow = new BorderHighlighter(HighlightPredicate.ROLLOVER_ROW, 
//                BorderFactory.createCompoundBorder(
                new MatteBorder(1, 0, 1, 0, Color.lightGray)
//                , BorderFactory.createEmptyBorder(0, 1, 0, 1))
                , true, false );  
        final AbstractHighlighter hlColumn = new ColorHighlighter(HighlightPredicate.ROLLOVER_COLUMN, 
                Color.LIGHT_GRAY, null);
        table.setHighlighters(hlRow, hlColumn);
        JXFrame frame = wrapWithScrollingInFrame(table, "borderHighlgihter on rollover");
        Action toggleCell = new AbstractAction("toggle cell-rollover") {
            
            @Override
            public void actionPerformed(ActionEvent e) {
                if (hlRow.getHighlightPredicate() == HighlightPredicate.ROLLOVER_ROW) {
                    hlRow.setHighlightPredicate(HighlightPredicate.NEVER);
                    hlColumn.setHighlightPredicate(HighlightPredicate.ROLLOVER_CELL);
                } else {
                    hlRow.setHighlightPredicate(HighlightPredicate.ROLLOVER_ROW);
                    hlColumn.setHighlightPredicate(HighlightPredicate.ROLLOVER_COLUMN);
                }
                
            }
        };
        addAction(frame, toggleCell);
        show(frame);
    }
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:43,代碼來源:HighlighterClientVisualCheck.java

示例5: interactiveTableAlternateAndRollover

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * LinePrinter striping and rollover.
 *
 */
public void interactiveTableAlternateAndRollover() {
    JXTable table = new JXTable(tableModel);
    table.setRowHeight(22);
    table.setHighlighters(
        HighlighterFactory.createSimpleStriping(HighlighterFactory.LINE_PRINTER),
        new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.YELLOW, null));
    showWithScrollingInFrame(table, "LinePrinter plus yellow rollover");
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:13,代碼來源:HighlighterClientVisualCheck.java

示例6: interactivePerRowImage

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * Use custom painter and highlighter for per-row image decoration.
 * 
 * @throws IOException
 */
public void interactivePerRowImage() throws IOException {
    
    JXTable table = new JXTable(new AncientSwingTeam());
    table.setForeground(Color.MAGENTA);
    table.setSelectionForeground(Color.BLUE);
    table.setColumnControlVisible(true);
    table.setRowHeight(25);
    final BufferedImage moon = XTestUtils.loadDefaultImage("moon.jpg");
    final BufferedImage rocket = XTestUtils.loadDefaultImage("500by500.png");
    HighlightPredicate rocketPredicate = new HighlightPredicate() {

        public boolean isHighlighted(Component renderer,
                ComponentAdapter adapter) {
            return ((Integer) adapter.getValue(3)).intValue() < 50;
        }
        
    };
    HighlightPredicate moonPredicate = new NotHighlightPredicate(rocketPredicate);
    table.setHighlighters(
            new SubImagePainterHighlighter(rocketPredicate, 
                    new SubImagePainter(rocket))
            ,
            new SubImagePainterHighlighter(moonPredicate, 
                    new SubImagePainter(moon))
    );
    JXFrame frame = wrapWithScrollingInFrame(table, "painter in renderer");
    show(frame);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:34,代碼來源:PainterVisualCheck.java

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

示例8: interactiveUITableWithAlternateRow

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
/**
 * UIHighlighter: check if highlighter is updated when toggling LF.
 */
public void interactiveUITableWithAlternateRow() {
    JXTable table = new JXTable(10, 2);
    table.setBackground(ledger);
    table.setHighlighters(HighlighterFactory.createSimpleStriping());
    JXTable nohighlight = new JXTable(10, 2);
    nohighlight.setBackground(ledger);
   showWithScrollingInFrame(table, nohighlight, "colored table with ui highlighter <--> without highlighter");
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:12,代碼來源:HighlighterIssues.java

示例9: Example_7a_View

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
public Example_7a_View() {
    super();
    setTitle(getClass().getSimpleName() + " " + ManagementFactory.getRuntimeMXBean().getName());

    setBounds(100, 100, 700, 500);
    setDefaultCloseOperation(StrictThreadingJFrame.EXIT_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    final JXTable table = new JXTable(myTableModel);
    table.setHighlighters(HighlighterFactory.createSimpleStriping());
    table.setSortable(false);
    table.getTableHeader().setReorderingAllowed(false);

    myTableModel.addTableModelListener(new TableModelListener() {

        int lastRowCountScrolledTo = -1;

        @Override
        public void tableChanged(final TableModelEvent e) {
            if (TableUtilities.isInsert(e)) {
                final int currentRowCount = myTableModel.getRowCount();
                if (currentRowCount != lastRowCountScrolledTo) {
                    lastRowCountScrolledTo = currentRowCount;
                    SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false)));
                }
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
}
 
開發者ID:Petikoch,項目名稱:Java_MVVM_with_Swing_and_RxJava_Examples,代碼行數:33,代碼來源:Example_7a_View.java

示例10: Example_7_View

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
public Example_7_View() {
    super();
    setTitle(getClass().getSimpleName() + " " + ManagementFactory.getRuntimeMXBean().getName());

    setBounds(100, 100, 700, 500);
    setDefaultCloseOperation(StrictThreadingJFrame.EXIT_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    final JXTable table = new JXTable(myTableModel);
    table.setHighlighters(HighlighterFactory.createSimpleStriping());
    table.setSortable(false);
    table.getTableHeader().setReorderingAllowed(false);

    myTableModel.addTableModelListener(new TableModelListener() {

        int lastRowCountScrolledTo = -1;

        @Override
        public void tableChanged(final TableModelEvent e) {
            if (TableUtilities.isInsert(e)) {
                final int currentRowCount = myTableModel.getRowCount();
                if (currentRowCount != lastRowCountScrolledTo) {
                    lastRowCountScrolledTo = currentRowCount;
                    SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false)));
                }
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
}
 
開發者ID:Petikoch,項目名稱:Java_MVVM_with_Swing_and_RxJava_Examples,代碼行數:33,代碼來源:Example_7_View.java

示例11: Example_8_View

import org.jdesktop.swingx.JXTable; //導入方法依賴的package包/類
public Example_8_View() {
    super();
    setTitle(getClass().getSimpleName() + " " + ManagementFactory.getRuntimeMXBean().getName());

    setBounds(100, 100, 700, 500);
    setDefaultCloseOperation(StrictThreadingJFrame.EXIT_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    final JXTable table = new JXTable(myTableModel);
    table.setHighlighters(HighlighterFactory.createSimpleStriping());
    table.setSortable(false);
    table.getTableHeader().setReorderingAllowed(false);

    myTableModel.addTableModelListener(new TableModelListener() {

        int lastRowCountScrolledTo = -1;

        @Override
        public void tableChanged(final TableModelEvent e) {
            if (TableUtilities.isInsert(e)) {
                final int currentRowCount = myTableModel.getRowCount();
                if (currentRowCount != lastRowCountScrolledTo) {
                    lastRowCountScrolledTo = currentRowCount;
                    SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false)));
                }
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
}
 
開發者ID:Petikoch,項目名稱:Java_MVVM_with_Swing_and_RxJava_Examples,代碼行數:33,代碼來源:Example_8_View.java


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