Java Code Examples for javax.swing.plaf.TableHeaderUI

The following examples show how to use javax.swing.plaf.TableHeaderUI. These examples are extracted from open source projects. 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 Project: netbeans   Source File: SortedTable.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setUI(TableHeaderUI ui) {
    /*
     * It fixes the bug by reseting the renderer to the default (non-sorting)
     * renderer before the UI is changed.
     * Thanks to this change (the reset), method
     * WindowsTableHeaderUI.uninstallUI(JComponent) then resets the
     * renderer to the default Windows L&F renderer which is the
     * renderer used when the Windows Classic theme is used.
     */
    if (ui != this.ui) {
        unsetSortingRenderer();
        super.setUI(ui);
        setSortingRenderer();
        repaint();
    }
}
 
Example 2
/**
 * Installs a corner filler that matches the table header. This is done to provide a continuous
 * appearance for tables with table headers placed in scroll panes.
 *
 * @param scrollpane Scroll pane.
 */
private void installTableHeaderCornerFiller(JScrollPane scrollpane) {
    // install custom scroll pane corner filler
    // for continuous painting of table headers
    JViewport columnHeader = scrollpane.getColumnHeader();
    // System.out.println("Column header " + columnHeader);
    if (columnHeader == null) {
        return;
    }
    Component columnHeaderComp = columnHeader.getView();
    // System.out.println("Column header comp " + columnHeaderComp);
    if (!(columnHeaderComp instanceof JTableHeader)) {
        return;
    }
    JTableHeader tableHeader = (JTableHeader) columnHeaderComp;
    TableHeaderUI tableHeaderUI = tableHeader.getUI();
    if (!(tableHeaderUI instanceof SubstanceTableHeaderUI)) {
        return;
    }
    SubstanceTableHeaderUI ui = (SubstanceTableHeaderUI) tableHeaderUI;
    JComponent scrollPaneCornerFiller = ui.getScrollPaneCornerFiller();
    String cornerKey = scrollpane.getComponentOrientation().isLeftToRight()
            ? JScrollPane.UPPER_RIGHT_CORNER
            : JScrollPane.UPPER_LEFT_CORNER;
    Component cornerComp = scrollpane.getCorner(cornerKey);
    // Corner component can be replaced when the current one is null or
    // UIResource
    boolean canReplace = (cornerComp == null) || (cornerComp instanceof UIResource);
    // System.out.println(canReplace + ":" + cornerComp);
    if (canReplace) {
        scrollpane.setCorner(cornerKey, scrollPaneCornerFiller);
    }
}
 
Example 3
/**
 * Handles various mouse move events and initiates the fade animation if necessary.
 * 
 * @param e
 *            Mouse event.
 */
private void handleMoveForHeader(MouseEvent e) {
    if (!SubstanceTableUI.this.table.getColumnSelectionAllowed())
        return;
    JTableHeader header = SubstanceTableUI.this.table.getTableHeader();
    if ((header == null) || (!header.isVisible()))
        return;

    TableHeaderUI ui = header.getUI();
    if (!(ui instanceof SubstanceTableHeaderUI))
        return;

    SubstanceTableHeaderUI sthui = (SubstanceTableHeaderUI) ui;

    // synchronized (SubstanceTableUI.this.table) {
    int row = SubstanceTableUI.this.table.rowAtPoint(e.getPoint());
    int column = SubstanceTableUI.this.table.columnAtPoint(e.getPoint());
    if ((row < 0) || (row >= SubstanceTableUI.this.table.getRowCount()) || (column < 0)
            || (column >= SubstanceTableUI.this.table.getColumnCount())) {
        this.fadeOutTableHeader();
        // System.out.println("Nulling RO column index");
        SubstanceTableUI.this.rolledOverColumn = -1;
    } else {
        // check if this is the same column
        if (SubstanceTableUI.this.rolledOverColumn == column)
            return;

        this.fadeOutTableHeader();

        TableColumnModel columnModel = header.getColumnModel();
        StateTransitionTracker columnTransitionTracker = sthui.getTracker(column, false,
                columnModel.getColumnSelectionAllowed()
                        && columnModel.getSelectionModel().isSelectedIndex(column));
        columnTransitionTracker.getModel().setRollover(true);

        SubstanceTableUI.this.rolledOverColumn = column;
    }
    // }
}
 
Example 4
/**
 * Maps {@code JTableHeader.getUI()} through queue
 */
public TableHeaderUI getUI() {
    return (runMapping(new MapAction<TableHeaderUI>("getUI") {
        @Override
        public TableHeaderUI map() {
            return ((JTableHeader) getSource()).getUI();
        }
    }));
}
 
Example 5
/**
 * Maps {@code JTableHeader.setUI(TableHeaderUI)} through queue
 */
public void setUI(final TableHeaderUI tableHeaderUI) {
    runMapping(new MapVoidAction("setUI") {
        @Override
        public void map() {
            ((JTableHeader) getSource()).setUI(tableHeaderUI);
        }
    });
}
 
Example 6
Source Project: netbeans   Source File: TaskListTable.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setUI(TableHeaderUI ui) {
    super.setUI(ui);
}
 
Example 7
Source Project: ramus   Source File: GroupableTableHeader.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setUI(TableHeaderUI ui) {
    super.setUI(new GroupableTableHeaderUI());
}