예제 #1
0
 protected void paintBackground(Graphics g) {
   int draggedColumn = -1;
   if ((header != null) && (header.getTable() != null) && header.getDraggedColumn() != null) {
     draggedColumn =
         header.getColumnModel().getColumnIndex(header.getDraggedColumn().getIdentifier());
   }
   int w = getWidth();
   int h = getHeight();
   if ((table != null) && table.isEnabled() && (col == rolloverCol || col == draggedColumn)) {
     JTattooUtilities.fillHorGradient(
         g, AbstractLookAndFeel.getTheme().getRolloverColors(), 0, 0, w, h);
     if (drawRolloverBar()) {
       g.setColor(AbstractLookAndFeel.getFocusColor());
       g.drawLine(0, 0, w - 1, 0);
       g.drawLine(0, 1, w - 1, 1);
       g.drawLine(0, 2, w - 1, 2);
     }
   } else if (drawAllwaysActive() || JTattooUtilities.isFrameActive(header)) {
     if (header.getBackground() instanceof ColorUIResource) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0, w, h);
     } else {
       g.setColor(header.getBackground());
       g.fillRect(0, 0, w, h);
     }
   } else {
     if (header.getBackground() instanceof ColorUIResource) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getInActiveColors(), 0, 0, w, h);
     } else {
       g.setColor(header.getBackground());
       g.fillRect(0, 0, w, h);
     }
   }
 }
  /**
   * Returns the default table cell renderer.
   *
   * @param table the <code>JTable</code>
   * @param value the value to assign to the cell at <code>[row, column]</code>
   * @param isSelected true if cell is selected
   * @param hasFocus true if cell has focus
   * @param row the row of the cell to render
   * @param column the column of the cell to render
   * @return the default table cell renderer
   */
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
      this.setBackground(table.getSelectionBackground());
      this.setForeground(table.getSelectionForeground());

    } else {
      this.setBackground(table.getBackground());
      this.setForeground(table.getForeground());
    }

    this.setEnabled(table.isEnabled());
    this.setFont(table.getFont());

    if (value instanceof CEMSystemActivity) {
      CEMSystemActivity activity = (CEMSystemActivity) value;
      int state = activity.getState();
      this.setText(activity.getText());
      if (state == CEMEntry.STATUS_ACCEPTED_INT || state == CEMEntry.STATUS_PENDING_INT) {
        Color backgroundColor = table.getBackground();
        if (state == CEMEntry.STATUS_ACCEPTED_INT) {
          backgroundColor = this.colorAccepted;
        } else if (state == CEMEntry.STATUS_PENDING_INT) {
          backgroundColor = this.colorPending;
        }
        if (isSelected) {
          this.setBackground(backgroundColor.darker());
        } else {
          this.setBackground(backgroundColor);
        }
      }
    }
    return (this);
  }
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean selected, boolean focused, int row, int column) {
      setEnabled(table == null || table.isEnabled());

      if (column == 0 || column == 1) {
        setHorizontalAlignment(SwingConstants.CENTER);
        setForeground(null);
        setBackground(null);
      } else {
        setHorizontalAlignment(SwingConstants.RIGHT);
        for (int i = 0; i < highlightIndex.size(); i++) {
          if (row == ((Integer) highlightIndex.elementAt(i)).intValue()) {
            setForeground(Color.blue);
            break;
          } else setForeground(null);
        }
        if (row == flashIndex) {
          setBackground(Color.orange);
        } else setBackground(null);
      }
      super.getTableCellRendererComponent(table, value, selected, focused, row, column);

      return this;
    }
예제 #4
0
 private boolean shouldIgnore(MouseEvent e) {
   return e.isConsumed() || (!(SwingUtilities.isLeftMouseButton(e) && table.isEnabled()));
 }