Search in sources :

Example 11 with JTableHeader

use of javax.swing.table.JTableHeader in project frostwire by frostwire.

the class AbstractTableMediator method handleHeaderColumnReleased.

/**
 * Tell the table something is not pressed.
 */
public void handleHeaderColumnReleased(Point p) {
    TABLE.setPressedColumnIndex(-1);
    JTableHeader th = TABLE.getTableHeader();
    int col = th.columnAtPoint(p);
    if (col != -1)
        // force the table to redraw the column header
        th.repaint(th.getHeaderRect(col));
}
Also used : JTableHeader(javax.swing.table.JTableHeader)

Example 12 with JTableHeader

use of javax.swing.table.JTableHeader in project jgnash by ccavanaugh.

the class BudgetPeriodPanel method layoutMainPanel.

private void layoutMainPanel() {
    FormLayout layout = new FormLayout("d:g", "d");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout, this);
    setLayout(layout);
    table = new AccountPeriodResultsTable(model);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setFocusable(false);
    table.setCellSelectionEnabled(false);
    JTableHeader header = new JTableHeader(table.getColumnModel());
    header.setReorderingAllowed(false);
    header.setResizingAllowed(false);
    header.setTable(table);
    buildHeader(header);
    buildFooter();
    JTableUtils.packTables(table, footerTable);
    builder.add(table, CC.xy(1, 1));
    setBorder(ShadowBorder.getCompondShadowBorder());
    ToolTipManager.sharedInstance().unregisterComponent(table);
    ToolTipManager.sharedInstance().unregisterComponent(header);
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder) JTableHeader(javax.swing.table.JTableHeader)

Example 13 with JTableHeader

use of javax.swing.table.JTableHeader in project jgnash by ccavanaugh.

the class AccountRowHeaderPanel method getTableHeader.

JPanel getTableHeader() {
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    header.setResizingAllowed(false);
    JPanel panel = new JXTitledPanel("  ", header);
    panel.setBorder(ShadowBorder.getCompondShadowBorder());
    return panel;
}
Also used : JPanel(javax.swing.JPanel) JXTitledPanel(org.jdesktop.swingx.JXTitledPanel) JTableHeader(javax.swing.table.JTableHeader)

Example 14 with JTableHeader

use of javax.swing.table.JTableHeader in project jdk8u_jdk by JetBrains.

the class TableSorter method addMouseListenerToHeaderInTable.

// Add a mouse listener to the Table to trigger a table sort
// when a column heading is clicked in the JTable.
public void addMouseListenerToHeaderInTable(JTable table) {
    tableView = table;
    columnModel = tableView.getColumnModel();
    JTableHeader th = tableView.getTableHeader();
    th.addMouseListener(this);
}
Also used : JTableHeader(javax.swing.table.JTableHeader)

Example 15 with JTableHeader

use of javax.swing.table.JTableHeader in project jdk8u_jdk by JetBrains.

the class SynthTableUI method paintCells.

private void paintCells(SynthContext context, Graphics g, int rMin, int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();
    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();
    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for (int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for (int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for (int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for (int column = cMin + 1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }
    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }
    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
Also used : Rectangle(java.awt.Rectangle) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point)

Aggregations

JTableHeader (javax.swing.table.JTableHeader)123 JTable (javax.swing.JTable)31 TableColumn (javax.swing.table.TableColumn)27 TableCellRenderer (javax.swing.table.TableCellRenderer)25 TableColumnModel (javax.swing.table.TableColumnModel)24 Component (java.awt.Component)21 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)19 JScrollPane (javax.swing.JScrollPane)17 MouseEvent (java.awt.event.MouseEvent)15 JLabel (javax.swing.JLabel)15 Color (java.awt.Color)11 MouseAdapter (java.awt.event.MouseAdapter)11 JPanel (javax.swing.JPanel)11 DefaultTableModel (javax.swing.table.DefaultTableModel)10 BorderLayout (java.awt.BorderLayout)9 Dimension (java.awt.Dimension)9 Point (java.awt.Point)9 JButton (javax.swing.JButton)8 JComponent (javax.swing.JComponent)8 JPopupMenu (javax.swing.JPopupMenu)7