Package javax.swing.table

Examples of javax.swing.table.JTableHeader$AccessibleJTableHeader


    }

    private class MouseHandler extends MouseAdapter {
        @Override
        public void mouseClicked(MouseEvent e) {
            JTableHeader h = (JTableHeader) e.getSource();
            TableColumnModel columnModel = h.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = columnModel.getColumn(viewColumn).getModelIndex();
            if (column != -1) {
                int status = getSortingStatus(column);
                if (!e.isControlDown()) {
View Full Code Here


                }

                //Implement table header tool tips.
                @Override
                protected JTableHeader createDefaultTableHeader() {
                    return new JTableHeader(columnModel) {
                        public String getToolTipText(MouseEvent e) {
                            java.awt.Point p = e.getPoint();
                            int index = columnModel.getColumnIndexAtX(p.x);
                            int realIndex = columnModel.getColumn(index).getModelIndex();
                            if (realIndex == LOG_LOGGER) {
View Full Code Here

    super(model, colModel, selModel);
    initSortHeader();
  }

  protected void initSortHeader() {
    JTableHeader header = getTableHeader();
    header.setDefaultRenderer(new SortHeaderRenderer());
    header.addMouseListener(this);
  }
View Full Code Here

                    sorter.sortByColumn(column, ascending);
                    lastSortedColumn = column;
                }
            }
        };
        JTableHeader th = tableView.getTableHeader();
        th.addMouseListener(listMouseListener);
    }
View Full Code Here

        return -1;
    }

    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();
    }
View Full Code Here

        return -1;
    }

    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();
    }
View Full Code Here

            Icon sortIcon = null;

            boolean isPaintingForPrint = false;

            if (table != null) {
                JTableHeader header = table.getTableHeader();

                if (header != null) {
                    Color fgColor = null;
                    Color bgColor = null;

                    if (hasFocus) {
                        fgColor = DefaultLookup.getColor(this, ui, "TableHeader.focusCellForeground");
                        bgColor = DefaultLookup.getColor(this, ui, "TableHeader.focusCellBackground");
                    }

                    if (fgColor == null) {
                        fgColor = header.getForeground();
                    }

                    if (bgColor == null) {
                        bgColor = header.getBackground();
                    }

                    setForeground(fgColor);
                    setBackground(bgColor);

                    setFont(header.getFont());

                    isPaintingForPrint = header.isPaintingForPrint();
                }

                if (!isPaintingForPrint && table.getRowSorter() != null) {
                    SortOrder sortOrder = getColumnSortOrder(table, column);
View Full Code Here

     * @param rMax    DOCUMENT ME!
     * @param cMin    DOCUMENT ME!
     * @param cMax    DOCUMENT ME!
     */
    private void paintCells(SeaGlassContext 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();
    }
View Full Code Here

                    boolean ascending = (shiftPressed == 0);
                    sorter.sortByColumn(column, ascending);
                }
             }
         };
        JTableHeader th = tableView.getTableHeader();
        th.addMouseListener(listMouseListener);
    }
View Full Code Here

            { "red", "beautiful" },
        };
        Object[] names = { "Color", "Type" };
        JTable table = new JTable(values, names);
        Frame frame = showFrame(new JScrollPane(table));
        JTableHeader header = table.getTableHeader();
        startRecording();
        int width = header.getSize().width;
        tester.actionDrag(header, 1, 1);
        assertStep("Drag");
        tester.actionDrop(header, width * 3 / 4, 1);
        assertStep("Drop");
        assertEquals("Column header not moved",
View Full Code Here

TOP

Related Classes of javax.swing.table.JTableHeader$AccessibleJTableHeader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.