Esempio n. 1
2
  public MainPanel() {
    super(new BorderLayout());

    InputMap im = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    KeyStroke stab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK);
    KeyStroke senter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK);
    im.put(tab, im.get(enter));
    im.put(stab, im.get(senter));

    final Color orgColor = table.getSelectionBackground();
    final Color tflColor = this.getBackground();
    table.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            table.setSelectionForeground(Color.WHITE);
            table.setSelectionBackground(orgColor);
          }

          @Override
          public void focusLost(FocusEvent e) {
            table.setSelectionForeground(Color.BLACK);
            table.setSelectionBackground(tflColor);
          }
        });

    table.setComponentPopupMenu(new TablePopupMenu());
    add(new JScrollPane(table));
    setPreferredSize(new Dimension(320, 240));
  }
Esempio n. 2
0
    public Component getTableCellRendererComponent(
        JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) {
      final String text = ((JButton) color).getText();
      setText(text);

      final Icon icon = ((JButton) color).getIcon();
      setIcon(icon);

      if (isSelected) {
        setForeground(table.getSelectionForeground());
        setBackground(table.getSelectionBackground());
      } else {
        setForeground(Color.black);
        setBackground(Color.white);
        if (row % 2 == 0) {
          // setBackground( new Color( 156, 207, 255 ) );
        }
      }

      if (isBordered) {
        if (isSelected) {
          if (selectedBorder == null) {
            selectedBorder =
                BorderFactory.createMatteBorder(2, 5, 2, 5, table.getSelectionBackground());
          }
          setBorder(selectedBorder);
        } else {
          if (unselectedBorder == null) {
            unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getBackground());
          }
          setBorder(unselectedBorder);
        }
      }
      return this;
    }
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSel, boolean hasFocus, int row, int column) {
    if (SubstanceLookAndFeel.isCurrentLookAndFeel()) {
      return getTableCellRendererComponentWithSubstance(table, value, isSel, hasFocus, row, column);
    } else {

      setValue(Math.min(100, getBarStatus(value)));
      setString(getDescription(value));

      Color uc = getBackgroundForRow(table, row);
      if (_selectedBorder == null && _unselectedBorder == null) {
        Color sc = table.getSelectionBackground();
        _selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, sc);
        _unselectedBorder = getCachedOrNewBorder(uc);
      }

      _unselectedBorder = getCachedOrNewBorder(uc);

      if (isSel) {
        setBorder(_selectedBorder);
        setBackground(table.getSelectionBackground());
      } else {
        setBorder(_unselectedBorder);
      }
      return this;
    }
  }
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

    if (value != null) setText(value.toString());
    if (isSelected) setBackground(table.getSelectionBackground());
    else {
      setBackground(table.getBackground());
      if (row == highlightedRowNum)
        setBackground(ColorUtil.setAlpha(table.getSelectionBackground(), 150));
    }

    return this;
  }
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (isSelected) {
     setForeground(table.getSelectionForeground());
     setBackground(table.getSelectionBackground());
   } else {
     setForeground(table.getForeground());
     setBackground(table.getBackground());
   }
   setFont(table.getFont());
   if (hasFocus) {
     setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
     if (table.isCellEditable(row, column)) {
       setForeground(UIManager.getColor("Table.focusCellForeground"));
       setBackground(UIManager.getColor("Table.focusCellBackground"));
     }
   } else {
     setBorder(new EmptyBorder(1, 2, 1, 2));
   }
   if (value != null) {
     setText(value.toString());
   } else {
     setText("");
   }
   adjustRowHeight(table, row, column);
   return this;
 }
Esempio n. 6
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   String str = Objects.toString(value, "");
   if (highlighter.isHighlightableCell(row, column)) {
     setText("<html><u>" + str);
     setForeground(isSelected ? table.getSelectionForeground() : HIGHLIGHT);
     setBackground(isSelected ? table.getSelectionBackground().darker() : table.getBackground());
   } else {
     setText(str);
     setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
     setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
   }
   return this;
 }
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

    if (value != null && value instanceof Peptide) {

      Peptide peptide = (Peptide) value;
      ptmString = getPTMString(peptide);
      // get the modifications
      java.util.List<Modification> mods = peptide.getModifications();
      // set the ptm string
      // set tooltips
      if (mods != null) {
        String tooltip = getToolTipText(mods, peptide.getSequence().length());
        if (!tooltip.trim().equals("")) {
          this.setToolTipText(tooltip);
        }
      }
      // set background
      if (isSelected) {
        this.setBackground(table.getSelectionBackground());
      } else {
        this.setBackground(table.getBackground());
      }
      // repaint the component
      this.revalidate();
      this.repaint();
    }
    return this;
  }
 /*
  * (non-Javadoc)
  *
  * @see org.protege.editor.owl.ui.renderer.OWLCellRenderer#
  * getTableCellRendererComponent(javax.swing.JTable, java.lang.Object,
  * boolean, boolean, int, int)
  */
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   Component comp;
   objectToRender = value;
   if (objectToRender instanceof OWLAxiomChange) {
     value = ((OWLOntologyChange) objectToRender).getAxiom();
   } else if (objectToRender instanceof OWLAxiomChange) {
     value = ((ImportChange) objectToRender).getImportDeclaration();
   } else if (objectToRender instanceof AddOntologyAnnotation) {
     value = ((AddOntologyAnnotation) objectToRender).getAnnotation();
   } else if (objectToRender instanceof RemoveOntologyAnnotation) {
     value = ((RemoveOntologyAnnotation) objectToRender).getAnnotation();
   } else {
     // do nothing
   }
   if (value instanceof String) {
     comp =
         defaultTableCellRenderer.getTableCellRendererComponent(
             table, value, isSelected, hasFocus, row, column);
   } else {
     comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   }
   if (isSelected) {
     comp.setForeground(table.getSelectionForeground());
     comp.setBackground(table.getSelectionBackground());
   } else {
     comp.setForeground(table.getForeground());
     comp.setBackground(table.getBackground());
   }
   return comp;
 }
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

    if (value != null) {
      DateFormat df = new SimpleDateFormat(DATETIME_FORMAT);
      df.setTimeZone(TimeZone.getDefault());
      setText(df.format((Long) value));
    } else setText("");

    setHorizontalAlignment(JLabel.LEFT);
    TableModel model = table.getModel();

    boolean valuesDiffer =
        model instanceof DesignTableModel ? ((DesignTableModel) model).isValuesDiffer(row) : false;
    if (valuesDiffer && !isSelected) {
      setForeground(table.getForeground());
      setBackground(DesignPanel.DIFFER_NO_FOCUS_COLOR);
    } else if (isSelected) {
      setForeground(table.getSelectionForeground());
      setBackground(table.getSelectionBackground());
    } else {
      setForeground(table.getForeground());
      setBackground(table.getBackground());
    }

    return this;
  }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   T t = (T) value;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     setText(t != null ? getItemText(t) : "");
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   final MyTableModel model = (MyTableModel) table.getModel();
   component.setEnabled(
       ElementsChooser.this.isEnabled()
           && (myColorUnmarkedElements ? model.isElementMarked(row) : true));
   final ElementProperties properties = myElementToPropertiesMap.get(t);
   if (component instanceof JLabel) {
     final Icon icon =
         properties != null ? properties.getIcon() : t != null ? getItemIcon(t) : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(
       properties != null && properties.getColor() != null
           ? properties.getColor()
           : (isSelected ? table.getSelectionForeground() : table.getForeground()));
   return component;
 }
  /**
   * 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);
  }
Esempio n. 12
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    textLabel.setFont(table.getFont());
    textLabel.setText(Objects.toString(value, ""));
    textLabel.setBorder(hasFocus ? focusCellHighlightBorder : noFocusBorder);

    FontMetrics fm = table.getFontMetrics(table.getFont());
    Insets i = textLabel.getInsets();
    int swidth =
        iconLabel.getPreferredSize().width + fm.stringWidth(textLabel.getText()) + i.left + i.right;
    int cwidth = table.getColumnModel().getColumn(column).getWidth();
    dim.width = swidth > cwidth ? cwidth : swidth;

    if (isSelected) {
      textLabel.setOpaque(true);
      textLabel.setForeground(table.getSelectionForeground());
      textLabel.setBackground(table.getSelectionBackground());
      iconLabel.setIcon(sicon);
    } else {
      textLabel.setOpaque(false);
      textLabel.setForeground(table.getForeground());
      textLabel.setBackground(table.getBackground());
      iconLabel.setIcon(nicon);
    }
    return panel;
  }
Esempio n. 13
0
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      try {
        // managing colors
        if (isSelected) {
          this.setBackground(table.getSelectionBackground());
          this.setForeground(table.getSelectionForeground());
        } else {
          this.setBackground(table.getSelectionForeground());
          this.setForeground(Color.BLACK);
        }

        OWLDescription desc = (OWLDescription) value;
        desc.accept(myVisitor);
        String str = myVisitor.result();
        myVisitor.reset();

        this.setText(str);
        // System.out.println( this.getText() );
      } catch (Exception e) {
        e.printStackTrace();
      }

      return this;
    }
Esempio n. 14
0
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
      setForeground(table.getSelectionForeground());
      setBackground(table.getSelectionBackground());
    } else {
      setForeground(table.getForeground());
      setBackground(table.getBackground());
    }

    String label = "";

    if (value instanceof Integer) {
      int val = ((Integer) value).intValue();

      if (val < 0 || val > 127) {
        label = "";
      } else {
        label = Integer.toString(val);
      }
    }

    this.setText(label);
    return this;
  }
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean cellHasFocus, int row, int col) {

    Color colour = (Color) value;

    int red = colour.getRed();
    int green = colour.getGreen();
    int blue = colour.getBlue();

    if (isSelected) {
      setBackground(table.getSelectionBackground());
      setForeground(table.getSelectionForeground());
    } else {
      setBackground(table.getBackground());
      setForeground(table.getForeground());
    }

    icon.setColour(colour);
    setIcon(icon);

    text.append(" [").append(red).append(",").append(green).append(",").append(blue).append("]");

    setText(text.toString());
    text.setLength(0);

    return this;
  }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (row < tv.getRowData().size()) {
     Vector line = (Vector) tv.getRowData().get(row);
     if (value != null) {
       setText(value.toString());
     }
     this.setOpaque(true);
     String searchStr = tv.getSearchString();
     String ceilStr = (String) line.get(column);
     boolean found =
         (searchStr != null
             && searchStr.length() > 0
             && ceilStr.toUpperCase().indexOf(searchStr.toUpperCase()) >= 0);
     Color backColor =
         (row % 2 == 0 && !isSelected)
             ? found ? searchBackColor : stripColor
             : (isSelected
                 ? table.getSelectionBackground()
                 : found ? searchBackColor : table.getBackground());
     Color foreColor =
         isSelected
             ? found ? searchStringColor : table.getSelectionForeground()
             : found ? searchStringColor : table.getForeground();
     setBackground(backColor);
     setForeground(foreColor);
   }
   return this;
 }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   final Module module = value instanceof Module ? (Module) value : null;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     if (module != null) {
       setText(
           module.getName()
               + " ("
               + FileUtil.toSystemDependentName(module.getModuleFilePath())
               + ")");
     }
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   component.setEnabled(ProcessedModulesTable.this.isEnabled());
   if (component instanceof JLabel) {
     final Icon icon = module != null ? ModuleType.get(module).getIcon() : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
   return component;
 }
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    setText((String) value);

    if (!isSelected) {
      if (row % 2 == 0) {

        this.setBackground(grey);
      } else {
        this.setBackground(Color.WHITE);
      }
    } else {
      this.setBackground(table.getSelectionBackground());
    }

    int fontHeight = this.getFontMetrics(this.getFont()).getHeight();
    int textLength = this.getText().length();
    int lines = 1;
    if (this.getColumns() != 0) {
      lines = textLength / this.getColumns() + 1; // +1, cause we need at least 1 row.
    }

    int height = fontHeight * lines;
    this.setPreferredSize(new Dimension(this.getWidth(), height));

    return this;
  }
Esempio n. 19
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) {

      if (isSelected) {
        setBackground(table.getSelectionBackground());
        setForeground(table.getSelectionForeground());
      } else {
        setForeground(table.getForeground());
        if (row % 2 == 0) {
          setBackground(EVEN_COLOR);
        } else {
          setBackground(ODD_COLOR);
        }
      }

      if (value != null && value instanceof Boolean) {

        Boolean imported = (Boolean) value;

        if (imported.booleanValue()) {
          this.setIcon(FLAG_ICON);
        } else {
          this.setIcon(null);
        }
        this.setText("");

      } else {
        setIcon(null);
        this.setText(value == null ? "" : value.toString());
      }
      return this;
    }
Esempio n. 20
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) {

      NLaboImportSummary summary = (NLaboImportSummary) tableModel.getObject(row);

      if (isSelected) {
        this.setBackground(table.getSelectionBackground());
        this.setForeground(table.getSelectionForeground());

      } else {
        if (summary != null && summary.getKarteId() == null) {

          this.setBackground(UNCONSTRAINED_COLOR);

        } else {

          if ((row & (1)) == 0) {
            this.setBackground(EVEN_COLOR);
          } else {
            this.setBackground(ODD_COLOR);
          }
        }

        this.setForeground(table.getForeground());
      }

      if (value != null && value instanceof String) {
        this.setText((String) value);
      } else {
        this.setText(value == null ? "" : value.toString());
      }
      return this;
    }
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    setOpaque(true);
    setFont(plainFont);
    // setBorder(new EmptyBorder(10, 10, 10, 6));

    if (isSelected) {
      setForeground(table.getSelectionForeground());
      setBackground(table.getSelectionBackground());
    } else {
      setForeground(table.getForeground());
      setBackground(table.getBackground());
    }

    if (table.getModel() instanceof FeedTableModel) {
      FeedTableModel rsstm = (FeedTableModel) table.getModel();
      TableColumn col = table.getColumnModel().getColumn(column);
      if (!rsstm.isItemAtRowRead(row)) setFont(boldFont);
      if (col.getHeaderValue() == FeedTableModel.READ) {
        if (rsstm.isItemAtRowRead(row)) setIcon(readItemIcon);
        else setIcon(unreadItemIcon);
      } else setIcon(null);

    } else if (table.getModel() instanceof WeblogTableModel) {
      WeblogTableModel btm = (WeblogTableModel) table.getModel();
      if (column == 0) {
        // is the modified column on the TableModel null?
        if (btm.getValueAt(row, WeblogTableModel.MODIFIED_COL) == null) setIcon(postIcon);
        else setIcon(uPostIcon);
      } else setIcon(null);
    }

    if (value instanceof FeedItem) {
      setText(((FeedItem) value).getTitle());
      return this;
    } else if (value instanceof Boolean) {
      setText("");
      setHorizontalAlignment(SwingConstants.CENTER);
      return this;
    } else if (value instanceof Integer) {
      Integer val = (Integer) value;
      setHorizontalAlignment(SwingConstants.CENTER);
      setText(val.intValue() + "");
      return this;
    } else if (value instanceof Date) {
      Date d = (Date) value;
      setText(df.format(d));
      if ((table.getModel() instanceof WeblogTableModel) && (column == WeblogTableModel.DATE_COL)) {
        if (expireDate != null && d.before(expireDate)) setForeground(Color.red);
      }

      return this;
    }

    setHorizontalAlignment(SwingConstants.LEFT);
    // setToolTipText(value.toString());
    if (value == null) setText("");
    else setText(value.toString());
    return this;
  }
Esempio n. 22
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) {

      if (isSelected) {
        setBackground(table.getSelectionBackground());
        setForeground(table.getSelectionForeground());
      } else {
        setForeground(table.getForeground());
        if (row % 2 == 0) {
          setBackground(EVEN_COLOR);
        } else {
          setBackground(ODD_COLOR);
        }
      }

      if (value != null && value instanceof String) {

        String pubType = (String) value;

        if (pubType.equals(IInfoModel.PUBLISHED_TYPE_GLOBAL)) {
          setIcon(WEB_ICON);
        } else {
          setIcon(HOME_ICON);
        }
        this.setText("");

      } else {
        setIcon(null);
        this.setText(value == null ? "" : value.toString());
      }
      return this;
    }
Esempio n. 23
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (isSelected) {
        renderButton.setForeground(table.getSelectionForeground());
        renderButton.setBackground(table.getSelectionBackground());
      } else {
        renderButton.setForeground(table.getForeground());
        renderButton.setBackground(UIManager.getColor("Button.background"));
      }

      renderButton.setFocusPainted(hasFocus);

      if (value == null) {
        renderButton.setText("");
        renderButton.setIcon(null);
      } else if (value instanceof Icon) {
        renderButton.setText("");
        renderButton.setIcon((Icon) value);
      } else {
        renderButton.setText(value.toString());
        renderButton.setIcon(null);
      }
      return renderButton;
    }
Esempio n. 24
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      //        //System.out.println(table.getModel().getClass().getSimpleName());
      Object tmp = table.getModel().getValueAt(row, 0);
      //        //System.out.println(Visualizer.findNode(tmp).getClass().getSimpleName());
      LabelSniffer ls = Visualizer.findNode(tmp).getLookup().lookup(LabelSniffer.class);
      try {
        if (ls != null) {
          //                    //System.out.println(actualCols[(column-1) * 2]);
          LabelProvider label;
          if ((label = ls.findLabelProvider(actualCols[(column - 1) * 2])) != null) {
            JLabel lab = label.getLabel();
            lab.setOpaque(isSelected);
            if (isSelected) {
              lab.setBackground(table.getSelectionBackground());
            }
            return label.getLabel();
          }
        }
      } catch (Exception ex) {
        ex.printStackTrace();
      }

      return new JLabel("tmp");
      //            //System.out.println("bez labela dla "+actualCols[(column-1) * 2]);
      //            Component comp = rend.getTableCellRendererComponent(table, value, isSelected,
      // hasFocus, row, column);
      //            return comp;
    }
Esempio n. 25
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      this.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());

      return this;
    }
Esempio n. 26
0
 private void setBackground(final JTable table, final boolean isSelected) {
   Color backgroundColor = table.getBackground();
   if (isSelected) {
     backgroundColor = table.getSelectionBackground();
   }
   cellComponent.setBorder(BorderFactory.createLineBorder(backgroundColor, 3));
   cellComponent.setBackground(backgroundColor);
 }
Esempio n. 27
0
    /** TreeCellRenderer method. Overridden to update the visible row. */
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (isSelected) setBackground(table.getSelectionBackground());
      else setBackground(table.getBackground());

      visibleRow = row;

      return this;
    }
 private static Component setLabelColors(
     final Component label, final JTable table, final boolean isSelected, final int row) {
   if (label instanceof JComponent) {
     ((JComponent) label).setOpaque(true);
   }
   label.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
   label.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
   return label;
 }
Esempio n. 29
0
 void greyOutTable() {
   sitesTable.setEnabled(false);
   oldSelectionBackground = sitesTable.getSelectionBackground();
   oldSelectionForeground = sitesTable.getSelectionForeground();
   sitesTable.setSelectionBackground(Color.GRAY);
   sitesTable.setSelectionForeground(Color.DARK_GRAY);
   sitesTable.setForeground(Color.GRAY);
   sitesTable.setBackground(null);
 }
Esempio n. 30
0
 protected void setColors(JTable table, int row, boolean isSelected) {
   if (!isSelected) {
     setBackground(rowColors[row % rowColors.length]);
     setForeground(table.getForeground());
   } else {
     setBackground(table.getSelectionBackground());
     setForeground(table.getSelectionForeground());
   }
 }