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) {
        sorting_column = column;

        // 0 == priority icon column
        // 4 == priority text column
        if (column == 0) sorting_column = 4;

        if (e.isControlDown()) sorting_column = -1;
        else opposite = !opposite;

        TaskTable treetable = ((TaskTable) h.getTable());

        // java.util.Collection expanded = treetable.getExpandedTreeNodes();

        treetable.tableChanged();
        // treetable.setExpandedTreeNodes(expanded);
        // h.updateUI();
        h.resizeAndRepaint();
      }
    }
 protected JTableHeader createDefaultTableHeader() {
   if (dataTableHeader == null) {
     dataTableHeader = new JTableHeader(getDataColumnModel());
     dataTableHeader.setResizingAllowed(true);
     dataTableHeader.setTable(dataTable);
   }
   return (dataTableHeader);
 }
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (table != null) {
        JTableHeader header = table.getTableHeader();
        if (header != null) {
          setFont(header.getFont());
        }
      }
      this.isSelected = isSelected;
      this.hasFocus = hasFocus;
      this.column = column;
      this.hasRollover = (column == rolloverColumn);
      if (skin == null || skin.getContentMargin() == null) {
        skin = XPStyle.getXP().getSkin(header, "header.headeritem");
      }
      setText((value == null) ? "" : value.toString());
      setBorder(new EmptyBorder(skin.getContentMargin()));

      return this;
    }
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (table != null) {
        JTableHeader header = table.getTableHeader();

        if (header != null) {
          setForeground(header.getForeground());
          setBackground(header.getBackground());
          setFont(header.getFont());
        }
      }

      if (isSelected) {
        setFont(getFont().deriveFont(Font.BOLD));
      }

      setText((value == null) ? "" : value.toString());
      setBorder(UIManager.getBorder("TableHeader.cellBorder"));

      return this;
    }
 public TaskTableSorter(TaskTable table) {
   JTableHeader tableHeader = table.getTableHeader();
   tableHeader.addMouseListener(new MouseHandler());
   tableHeader.setDefaultRenderer(new SortableHeaderRenderer());
 }
Beispiel #6
0
 public void allowSortColChange(boolean allow) {
   JTableHeader hdr = table.getTableHeader();
   if (allow && !allowSortColChange) hdr.addMouseListener(allowSortColChangeMouseListener);
   else if (!allow && allowSortColChange) hdr.removeMouseListener(allowSortColChangeMouseListener);
   allowSortColChange = allow;
 }