Package javax.swing.table

Examples of javax.swing.table.TableCellRenderer


            if (row >= 0 && column >= 0) {
                Rectangle cellBounds = table.getCellRect(row, column, false);
                X -= cellBounds.x;
                Y -= cellBounds.y;

                TableCellRenderer renderer = table.getCellRenderer(row, column);
                if (renderer != null) {
                    Component c = renderer.getTableCellRendererComponent(table, table.getValueAt(row, column), false, false, row, column);
                    params.put("child", new ParameterHolder(c));
                }
            }
        }
        else if (pControl != null && pControl instanceof JTree)
View Full Code Here


    return stateColour;
  }

  public void setStateColour(StateColourForRow stateColour) {
    this.stateColour = stateColour;
    TableCellRenderer renderer = ((ArrayFieldCellRenderer)this.getCellRenderer()).getRenderer();
    // TF:10/02/2009:Changed this to use an interface
    if (renderer instanceof StateColourForRowDisplayer){
      ((StateColourForRowDisplayer)renderer).setStateColour(stateColour);
    }
    TableCellEditor editor = this.getCellEditor();
View Full Code Here

                ((JScrollPane)af.getParent().getParent()).setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            }
           
            // Expand any text fields that are in the array field
            for (int i=0; i<af.getColumnCount(); i++) {
              TableCellRenderer cellRenderer = af.getCellRenderer(0, i);
             
              if (cellRenderer instanceof ArrayFieldCellRenderer &&
                  ((ArrayFieldCellRenderer)cellRenderer).getRenderer() instanceof TextFieldCellRenderer) {
                ((TextFieldCellRenderer)((ArrayFieldCellRenderer)cellRenderer).getRenderer()).setPrinting(removeScrollBars);
              }
View Full Code Here

    public JComponent getChildInCell(int pRow, int pColumn, boolean getEditor) {
        pRow -= 1;
        pColumn -=1;
        ArrayColumnModel model = (ArrayColumnModel)this.table.getColumnModel();
        TableCellEditor editor = model.getRealColumn(pColumn).getCellEditor();
        TableCellRenderer renderer = model.getRealColumn(pColumn).getCellRenderer();

        if (editor instanceof ArrayFieldCellEditor) {
            editor = ((ArrayFieldCellEditor)editor).getEditor();
        }
        if (renderer instanceof ArrayFieldCellRenderer) {
            renderer = ((ArrayFieldCellRenderer)renderer).getRenderer();
        }
        JComponent c;
        if (getEditor) {
          // Not used anymore.  CraigM: 27/02/2008
//            if (editor instanceof ComponentCellEditor) {
//                c = (JComponent)((ComponentCellEditor)editor).getComponent();
//            }
//            else if (editor instanceof DefaultCellEditor) {
          if (editor instanceof DefaultCellEditor) {
                c = (JComponent)((DefaultCellEditor)editor).getComponent();
            }
            else {
              //c = (JComponent)editor.getTableCellEditorComponent(this.table, this.table.getValueAt(pRow, pColumn), false, pRow, pColumn);
                c = (JComponent)editor.getTableCellEditorComponent(this.table, this.table.getModel().getValueAt(pRow, pColumn), false, pRow, pColumn);
            }

        } else {
          // Not used anymore.  CraigM: 27/02/2008
//            if (renderer instanceof ComponentCellRenderer) {
//                c = (JComponent)((ComponentCellRenderer)renderer).getTableColumnTemplate();
//            }
//            else {
          //c = (JComponent)renderer.getTableCellRendererComponent(this.table, this.table.getValueAt(pRow, pColumn), false, false, pRow, pColumn);
          c = (JComponent)renderer.getTableCellRendererComponent(this.table, this.table.getModel().getValueAt(pRow, pColumn), false, false, pRow, pColumn);
//            }
        }
        BodyGridCell cell = this.getCell(pRow, pColumn, true);
        cell.setTemplate(c);
        return c;
View Full Code Here

            // it. Hence we need to listen for it on the array as well
            // _installOnChild(pRoot, pParent, table, pEvent, pInstaller);
            TableColumnModel cm = table.getColumnModel();
            for (int c = 0; c < cm.getColumnCount(); c++){
                TableColumn tc = cm.getColumn(c);
                TableCellRenderer tcr = tc.getCellRenderer();

                // Handle ArrayFieldCellRenderer. CraigM 30/08/2007
                if (tcr != null && tcr instanceof ArrayFieldCellRenderer) {
                    tcr = ((ArrayFieldCellRenderer)tcr).getRenderer();
                }
                // TF:28/9/07:Removed this dependancy on the FormattedCellRenderer, not sure why it was there. Also changed to the correct column
                if (tcr != null /*&& !(tcr instanceof FormattedCellRenderer)*/){
                    JComponent cr = (JComponent)tcr.getTableCellRendererComponent(table, null, false, false, 0, c);
                    // TF:28/9/07:Some of our "atomic" children are comprised of other children. For example, a radiolist is a JList
                    // with scrollbars, a drop list has a drop list
                    //if (cr.getComponentCount() == 0) {
                        _installOnChild(pRoot, table, cr, pEvent, pInstaller);
                    //}
View Full Code Here

    public JComponent getChildInCell(int pRow, int pColumn, boolean getEditor) {
        pRow -= 1;
        pColumn -=1;
        ArrayColumnModel model = (ArrayColumnModel)this.table.getColumnModel();
        TableCellEditor editor = model.getRealColumn(pColumn).getCellEditor();
        TableCellRenderer renderer = model.getRealColumn(pColumn).getCellRenderer();

        if (editor instanceof ArrayFieldCellEditor) {
            editor = ((ArrayFieldCellEditor)editor).getEditor();
        }
        if (renderer instanceof ArrayFieldCellRenderer) {
            renderer = ((ArrayFieldCellRenderer)renderer).getRenderer();
        }
        JComponent c;
        if (getEditor) {
          // Not used anymore.  CraigM: 27/02/2008
//            if (editor instanceof ComponentCellEditor) {
//                c = (JComponent)((ComponentCellEditor)editor).getComponent();
//            }
//            else if (editor instanceof DefaultCellEditor) {
          if (editor instanceof DefaultCellEditor) {
                c = (JComponent)((DefaultCellEditor)editor).getComponent();
            }
            else {
              //c = (JComponent)editor.getTableCellEditorComponent(this.table, this.table.getValueAt(pRow, pColumn), false, pRow, pColumn);
                c = (JComponent)editor.getTableCellEditorComponent(this.table, this.table.getModel().getValueAt(pRow, pColumn), false, pRow, pColumn);
            }

        } else {
          // Not used anymore.  CraigM: 27/02/2008
//            if (renderer instanceof ComponentCellRenderer) {
//                c = (JComponent)((ComponentCellRenderer)renderer).getTableColumnTemplate();
//            }
//            else {
          //c = (JComponent)renderer.getTableCellRendererComponent(this.table, this.table.getValueAt(pRow, pColumn), false, false, pRow, pColumn);
          c = (JComponent)renderer.getTableCellRendererComponent(this.table, this.table.getModel().getValueAt(pRow, pColumn), false, false, pRow, pColumn);
//            }
        }
        BodyGridCell cell = this.getCell(pRow, pColumn, true);
        cell.setTemplate(c);
        return c;
View Full Code Here

    if (headerFontStyle != Font.PLAIN) {
      header.setFont(header.getFont().deriveFont(headerFontStyle));
    }

    // Make the header look like Forte - Simple labels.  CraigM 23/08/2007.
    header.setDefaultRenderer( new TableCellRenderer() {
      public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column ) {
        if (ArrayField.this.getColumnModel().getColumn(column) instanceof ArrayColumn) {
          // TF:25/08/2009:DET-112:Changed this to instantiate a TextGraphic instead of a JLabel
          // because code that gets the header through ArrayField.getColumnTitle() is expecting a TextGraphic
          //                  JLabel label = new JLabel(value.toString());
View Full Code Here

          // Details in rectangle place holders
          if (this.paintEmptyRowRectangles && rowHeight > inset*2 && column.getWidth() > inset*2) {

            // If we can append a row, we are on the last row, and this column is editable
            if (this.isAllowsAppendAndEditable() && row == rowCount && model.isColumnEditable(col)) {
              TableCellRenderer renderer = ((ArrayFieldCellRenderer)column.getCellRenderer()).getRenderer();

              // The renderer supports painting in an empty row.  CraigM:20/01/2009.
              if (renderer instanceof ArrayFieldEmptyCellRenderer) {
                // Paint an editable row (not faded)
                // TF:27/11/2009:Changed this to pass in the width, which allows us to draw the proper image when the column is resized.
                BufferedImage img = ((ArrayFieldEmptyCellRenderer)renderer).getImage(column.getWidth());
                g.drawImage(img, xPos + ((column.getWidth() - img.getWidth()) / 2), (row*rowHeight) + ((rowHeight - img.getHeight()) / 2), null);
              }

              // Draw a filled white rectangle
              else {
                Color emptyCellColor = backgroundColour.equals(Color.gray) ? Color.lightGray : Color.gray;
                g.setColor(emptyCellColor);
                g.drawRect(xPos+inset, (row*rowHeight)+inset, column.getWidth()-(inset*2), rowHeight-(inset*2));
              }
            }
            else {
              TableCellRenderer renderer = ((ArrayFieldCellRenderer)column.getCellRenderer()).getRenderer();

              // The renderer supports painting in an empty row.  CraigM:20/01/2009.
              if (renderer instanceof ArrayFieldEmptyCellRenderer) {
                // These are non editable rows, so fade them out a little
                ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
View Full Code Here

                      c = ((ArrayTableComponentCorrector)c).correctPostingComponent();
          }
        }

        if (c == null) {
          TableCellRenderer tcr = getCellRenderer(row, column);
          if (tcr != null) {
            c = tcr.getTableCellRendererComponent(ArrayField.this, getValueAt(row, column), false, false, row, column);
          }
        }

        // If the component is editable, then the event will be fired in the EditCellAt method.  CraigM: 28/03/2008.
        if (this.isCellEditable(row, column) == false) {
View Full Code Here

    int hitColumnIndex = columnAtPoint(p);
    int hitRowIndex = rowAtPoint(p);
    Component component = null;

    if ((hitColumnIndex != -1) && (hitRowIndex != -1)) {
      TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex);
      component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex);

      // DK:19/08/2008:get a real renderer component instead of wrapper panel. See ArrayFieldCellRenderer.
      if (component instanceof JPanel) {
        JPanel wrapPanel = (JPanel) component;
View Full Code Here

TOP

Related Classes of javax.swing.table.TableCellRenderer

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.