Example usage for javax.swing.table TableColumn setCellEditor

List of usage examples for javax.swing.table TableColumn setCellEditor

Introduction

In this page you can find the example usage for javax.swing.table TableColumn setCellEditor.

Prototype

@BeanProperty(description = "The editor to use for cell values.")
public void setCellEditor(TableCellEditor cellEditor) 

Source Link

Document

Sets the editor to used by when a cell in this column is edited.

Usage

From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java

private void setValues() {
    log.debug("invoking setValues()");
    jTextFieldStatus.setText("Loading");

    jTextFieldBarcode.setText(specimen.getBarcode());
    jComboBoxLocationInCollection.setSelectedItem(specimen.getLocationInCollection());
    cbTypeStatus.setSelectedItem(specimen.getTypeStatus());
    jTextFieldDrawerNumber.setText(specimen.getDrawerNumber());
    jComboBoxFamily.setSelectedItem(specimen.getFamily());
    jComboBoxSubfamily.setSelectedItem(specimen.getSubfamily());
    jTextFieldTribe.setText(specimen.getTribe());
    jTextFieldGenus.setText(specimen.getGenus());
    jTextFieldSpecies.setText(specimen.getSpecificEpithet());
    jTextFieldSubspecies.setText(specimen.getSubspecificEpithet());
    jTextFieldInfraspecificEpithet.setText(specimen.getInfraspecificEpithet());
    jTextFieldInfraspecificRank.setText(specimen.getInfraspecificRank());
    jTextFieldAuthorship.setText(specimen.getAuthorship());

    jTextFieldIdRemarks.setText(specimen.getIdentificationRemarks());
    jTextFieldDateDetermined.setText(specimen.getDateIdentified());

    MCZbaseAuthAgentName selection = new MCZbaseAuthAgentName();
    selection.setAgent_name(specimen.getIdentifiedBy());
    ((AgentNameComboBoxModel) jCBDeterminer.getModel()).setSelectedItem(selection);
    jCBDeterminer.getEditor().setItem(jCBDeterminer.getModel().getSelectedItem());

    jComboBoxNatureOfId.setSelectedItem(specimen.getNatureOfId());

    jTextFieldUnnamedForm.setText(specimen.getUnNamedForm());
    jTextFieldVerbatimLocality.setText(specimen.getVerbatimLocality());
    // Specimen record contains a string, delegate handling of lookup of object to the combo box model.
    log.debug(specimen.getHigherGeography());
    ((HigherGeographyComboBoxModel) comboBoxHigherGeog.getModel())
            .setSelectedItem(specimen.getHigherGeography());
    //TODO ? set model not notifying listeners?       
    comboBoxHigherGeog.getEditor().setItem(comboBoxHigherGeog.getModel().getSelectedItem());
    jTextFieldCountry.setText(specimen.getCountry());
    if (specimen.getValidDistributionFlag() != null) {
        jCheckBoxValidDistributionFlag.setSelected(specimen.getValidDistributionFlag());
    } else {/*  w  w  w .  jav  a2 s.  c o  m*/
        jCheckBoxValidDistributionFlag.setSelected(false);
    }
    jTextFieldPrimaryDivision.setText(specimen.getPrimaryDivison());
    jTextFieldLocality.setText(specimen.getSpecificLocality());

    // Elevations  **********************************************************************
    try {
        jTextFieldMinElevation.setText(Long.toString(specimen.getMinimum_elevation()));
    } catch (Exception e) {
        jTextFieldMinElevation.setText("");
    }
    try {
        textFieldMaxElev.setText(Long.toString(specimen.getMaximum_elevation()));
    } catch (Exception e) {
        textFieldMaxElev.setText("");
    }
    if (specimen.getElev_units() != null) {
        comboBoxElevUnits.setSelectedItem(specimen.getElev_units());
    } else {
        comboBoxElevUnits.setSelectedItem("");
    }

    jTextFieldCollectingMethod.setText(specimen.getCollectingMethod());
    jTextFieldISODate.setText(specimen.getIsoDate());
    jTextFieldDateNos.setText(specimen.getDateNos());
    jTextFieldDateCollected.setText(specimen.getDateCollected());
    jTextFieldDateEmerged.setText(specimen.getDateEmerged());
    jTextFieldDateCollectedIndicator.setText(specimen.getDateCollectedIndicator());
    jTextFieldDateEmergedIndicator.setText(specimen.getDateEmergedIndicator());
    jComboBoxCollection.setSelectedItem(specimen.getCollection());
    //jTextFieldPreparationType.setText(specimen.getPreparationType());
    jTextFieldAssociatedTaxon.setText(specimen.getAssociatedTaxon());
    jTextFieldHabitat.setText(specimen.getHabitat());
    jTextAreaSpecimenNotes.setText(specimen.getSpecimenNotes());
    jComboBoxFeatures.setSelectedItem(specimen.getFeatures());
    jComboBoxLifeStage.setSelectedItem(specimen.getLifeStage());
    jComboBoxSex.setSelectedItem(specimen.getSex());
    jTextFieldCitedInPub.setText(specimen.getCitedInPublication());
    jTextFieldQuestions.setText(specimen.getQuestions());
    jComboBoxWorkflowStatus.setSelectedItem(specimen.getWorkFlowStatus());
    if (specimen.isStateDone()) {
        jLabelMigrationStatus.setText("http://mczbase.mcz.harvard.edu/guid/MCZ:Ent:" + specimen.getCatNum());
    } else {
        jLabelMigrationStatus.setText("");
    }
    jTextFieldInferences.setText(specimen.getInferences());
    jTextFieldCreator.setText(specimen.getCreatedBy());
    if (specimen.getDateCreated() != null) {
        jTextFieldDateCreated.setText(specimen.getDateCreated().toString());
    }
    jTextFieldLastUpdatedBy.setText(specimen.getLastUpdatedBy());
    if (specimen.getDateLastUpdated() != null) {
        jTextFieldDateLastUpdated.setText(specimen.getDateLastUpdated().toString());
    }

    jTableNumbers.setModel(new NumberTableModel(specimen.getNumbers()));
    // Setting the model will overwrite the existing cell editor bound 
    // to the column model, so we need to add it again.
    JTextField field1 = new JTextField();
    field1.setInputVerifier(MetadataRetriever.getInputVerifier(edu.harvard.mcz.imagecapture.data.Number.class,
            "Number", field1));
    field1.setVerifyInputWhenFocusTarget(true);
    jTableNumbers.getColumnModel().getColumn(0).setCellEditor(new ValidatingTableCellEditor(field1));
    JComboBox<String> jComboNumberTypes = new JComboBox<String>();
    jComboNumberTypes.setModel(new DefaultComboBoxModel<String>(NumberLifeCycle.getDistinctTypes()));
    jComboNumberTypes.setEditable(true);
    TableColumn typeColumn = jTableNumbers.getColumnModel().getColumn(NumberTableModel.COLUMN_TYPE);
    typeColumn.setCellEditor(new DefaultCellEditor(jComboNumberTypes));

    jTableCollectors.setModel(new CollectorTableModel(specimen.getCollectors()));
    // Setting the model will overwrite the existing cell editor bound 
    // to the column model, so we need to add it again.
    // JTextField field = new JTextField();
    FilteringAgentJComboBox field = new FilteringAgentJComboBox();
    //field.setInputVerifier(MetadataRetriever.getInputVerifier(Collector.class, "CollectorName", field));
    //jTableCollectors.getColumnModel().getColumn(0).setCellEditor(new PicklistTableCellEditor(field, true));
    jTableCollectors.getColumnModel().getColumn(0).setCellEditor(new ComboBoxCellEditor(field));
    //field.setInputVerifier(MetadataRetriever.getInputVerifier(Collector.class, "CollectorName", field));
    //field.setVerifyInputWhenFocusTarget(true);
    //jTableCollectors.getColumnModel().getColumn(0).setCellEditor(new ValidatingTableCellEditor(field));

    jTableSpecimenParts.setModel(new SpecimenPartsTableModel(specimen.getSpecimenParts()));
    jTableSpecimenParts.getColumnModel().getColumn(0).setPreferredWidth(90);
    for (int i = 0; i < jTableSpecimenParts.getColumnCount(); i++) {
        TableColumn column = jTableSpecimenParts.getColumnModel().getColumn(i);
        if (i == 0) {
            column.setPreferredWidth(120);
        } else {
            column.setPreferredWidth(50);
        }
    }
    setSpecimenPartsTableCellEditors();

    updateDeterminationCount();

    if (specimen.getICImages() != null) {
        int imageCount = specimen.getICImages().size();
        jTextFieldImageCount.setText("Number of Images=" + imageCount);
        if (imageCount > 1) {
            jTextFieldImageCount.setForeground(Color.RED);
        } else {
            jTextFieldImageCount.setForeground(Color.BLACK);
        }
    }

    setWarnings();
    this.setStateToClean();
    jTextFieldStatus.setText("Loaded");
}

From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java

/**
 * This method initializes jTable   //from  w  w w.j a v a2s. com
 *    
 * @return javax.swing.JTable   
 */
private JTable getJTable() {
    if (jTableNumbers == null) {
        jTableNumbers = new JTable(new NumberTableModel());
        JComboBox<String> jComboNumberTypes = new JComboBox<String>();
        jComboNumberTypes.setModel(new DefaultComboBoxModel<String>(NumberLifeCycle.getDistinctTypes()));
        jComboNumberTypes.setEditable(true);
        TableColumn typeColumn = jTableNumbers.getColumnModel().getColumn(NumberTableModel.COLUMN_TYPE);
        DefaultCellEditor comboBoxEditor = new DefaultCellEditor(jComboNumberTypes);
        //TODO: enable autocomplete for numbertypes picklist.
        //AutoCompleteDecorator.decorate((JComboBox) comboBoxEditor.getComponent());
        typeColumn.setCellEditor(comboBoxEditor);
        DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
        renderer.setToolTipText("Click for pick list of number types.");
        typeColumn.setCellRenderer(renderer);
        jTableNumbers.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent e) {
                thisPane.setStateToDirty();
            }
        });

        jTableNumbers.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                if (e.isPopupTrigger()) {
                    clickedOnNumsRow = ((JTable) e.getComponent()).getSelectedRow();
                    jPopupNumbers.show(e.getComponent(), e.getX(), e.getY());
                }
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                if (e.isPopupTrigger()) {
                    clickedOnNumsRow = ((JTable) e.getComponent()).getSelectedRow();
                    jPopupNumbers.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        });

        jPopupNumbers = new JPopupMenu();
        JMenuItem mntmDeleteRow = new JMenuItem("Delete Row");
        mntmDeleteRow.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    if (clickedOnNumsRow >= 0) {
                        int ok = JOptionPane.showConfirmDialog(thisPane, "Delete the selected number?",
                                "Delete Number", JOptionPane.OK_CANCEL_OPTION);
                        if (ok == JOptionPane.OK_OPTION) {
                            log.debug("deleting numbers row " + clickedOnNumsRow);
                            ((NumberTableModel) jTableNumbers.getModel()).deleteRow(clickedOnNumsRow);
                            setStateToDirty();
                        } else {
                            log.debug("number row delete canceled by user.");
                        }
                    } else {
                        JOptionPane.showMessageDialog(thisPane,
                                "Unable to select row to delete.  Try empting number and type and pressing Save.");
                    }
                } catch (Exception ex) {
                    log.error(ex.getMessage());
                    JOptionPane.showMessageDialog(thisPane,
                            "Failed to delete a number row. " + ex.getMessage());
                }
            }
        });
        jPopupNumbers.add(mntmDeleteRow);
    }
    return jTableNumbers;
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java

/**
 * Adjust all the column width for the data in the column, this may be handles with JDK 1.6 (6.)
 * @param tableArg the table that should have it's columns adjusted
 *//*  w  w w  .j  a  v a2 s . c o m*/
private void initColumnSizes(final JTable tableArg, final JButton theSaveBtn) throws Exception {
    TableModel tblModel = tableArg.getModel();
    TableColumn column = null;
    Component comp = null;
    int headerWidth = 0;
    int cellWidth = 0;

    Element uploadDefs = null;
    if (WorkbenchTask.isCustomizedSchema()) {
        uploadDefs = XMLHelper.readFileToDOM4J(
                new File(UIRegistry.getAppDataDir() + File.separator + "specify_workbench_upload_def.xml"));
    } else {
        uploadDefs = XMLHelper.readDOMFromConfigDir("specify_workbench_upload_def.xml");
    }

    //UIRegistry.getInstance().hookUpUndoableEditListener(cellEditor);

    Vector<WorkbenchTemplateMappingItem> wbtmis = new Vector<WorkbenchTemplateMappingItem>();
    wbtmis.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems());
    Collections.sort(wbtmis);

    DBTableIdMgr databaseSchema = WorkbenchTask.getDatabaseSchema();

    columnMaxWidths = new Integer[tableArg.getColumnCount()];
    for (int i = 0; i < wbtmis.size() /*tableArg.getColumnCount()*/; i++) {
        TableCellRenderer headerRenderer = tableArg.getColumnModel().getColumn(i).getHeaderRenderer();
        WorkbenchTemplateMappingItem wbtmi = wbtmis.elementAt(i);

        // Now go retrieve the data length
        int fieldWidth = WorkbenchDataItem.getMaxWBCellLength();
        DBTableInfo ti = databaseSchema.getInfoById(wbtmi.getSrcTableId());
        if (ti != null) {
            DBFieldInfo fi = ti.getFieldByName(wbtmi.getFieldName());
            if (fi != null) {
                wbtmi.setFieldInfo(fi);
                //System.out.println(fi.getName()+"  "+fi.getLength()+"  "+fi.getType());
                if (RecordTypeCodeBuilder.getTypeCode(fi) == null && fi.getLength() > 0) {
                    fieldWidth = Math.min(fi.getLength(), WorkbenchDataItem.getMaxWBCellLength());
                }
            } else {
                log.error("Can't find field with name [" + wbtmi.getFieldName() + "]");
            }
        } else {
            log.error("Can't find table [" + wbtmi.getSrcTableId() + "]");
        }
        columnMaxWidths[i] = new Integer(fieldWidth);
        GridCellEditor cellEditor = getCellEditor(wbtmi, fieldWidth, theSaveBtn, uploadDefs);
        column = tableArg.getColumnModel().getColumn(i);

        comp = headerRenderer.getTableCellRendererComponent(null, column.getHeaderValue(), false, false, 0, 0);
        headerWidth = comp.getPreferredSize().width;

        comp = tableArg.getDefaultRenderer(tblModel.getColumnClass(i)).getTableCellRendererComponent(tableArg,
                tblModel.getValueAt(0, i), false, false, 0, i);

        cellWidth = comp.getPreferredSize().width;

        //comp.setBackground(Color.WHITE);

        int maxWidth = headerWidth + 10;
        TableModel m = tableArg.getModel();
        FontMetrics fm = comp.getFontMetrics(comp.getFont());
        for (int row = 0; row < tableArg.getModel().getRowCount(); row++) {
            String text = m.getValueAt(row, i).toString();
            maxWidth = Math.max(maxWidth, fm.stringWidth(text) + 10);
            //log.debug(i+" "+maxWidth);
        }

        //XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
        //log.debug(Math.max(maxWidth, cellWidth));
        //log.debug(Math.min(Math.max(maxWidth, cellWidth), 400));
        column.setPreferredWidth(Math.min(Math.max(maxWidth, cellWidth), 400));

        column.setCellEditor(cellEditor);
    }
    //tableArg.setCellEditor(cellEditor);
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public void setStandardFont(Font theFont) {
    standardFont = theFont;//from   w  w w.j a v a  2 s .  c  om
    resetTrees(standardFont.getSize());

    if (theMetaDataTable != null) {
        TableColumn col = theMetaDataTable.getColumnModel().getColumn(1);
        col.setCellEditor(new MetaDataElementCellEditor(standardFont));
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

private void setupMetaDataColumns() {
    TableRenderer renderer = new TableRenderer();
    TableColumn col = theMetaDataTable.getColumnModel().getColumn(0);
    col.setCellRenderer(renderer);/*  w w w  .ja va2s .c  om*/
    col.setResizable(true);
    col = theMetaDataTable.getColumnModel().getColumn(1);
    col.setCellRenderer(renderer);
    col.setCellEditor(new MetaDataElementCellEditor(standardFont));
}

From source file:org.apache.cayenne.modeler.editor.ObjEntityRelationshipPanel.java

protected void rebuildTable(ObjEntity entity) {
    final ObjRelationshipTableModel model = new ObjRelationshipTableModel(entity, mediator, this);

    model.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            if (table.getSelectedRow() >= 0) {
                ObjRelationship rel = model.getRelationship(table.getSelectedRow());
                enabledResolve = rel.getSourceEntity().getDbEntity() != null;
                resolveMenu.setEnabled(enabledResolve);
            }//from w  ww .j  a v a 2  s . c o m
        }
    });

    table.setModel(model);
    table.setRowHeight(25);
    table.setRowMargin(3);

    TableColumn col = table.getColumnModel().getColumn(ObjRelationshipTableModel.REL_TARGET_PATH);
    col.setCellEditor(new DbRelationshipPathComboBoxEditor());
    col.setCellRenderer(new DefaultTableCellRenderer() {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
            setToolTipText(
                    "To choose relationship press enter two times.To choose next relationship press dot.");
            return this;
        }
    });

    col = table.getColumnModel().getColumn(ObjRelationshipTableModel.REL_DELETE_RULE);
    JComboBox deleteRulesCombo = Application.getWidgetFactory().createComboBox(DELETE_RULES, false);
    deleteRulesCombo.setFocusable(false);
    deleteRulesCombo.setEditable(true);
    ((JComponent) deleteRulesCombo.getEditor().getEditorComponent()).setBorder(null);
    deleteRulesCombo.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    deleteRulesCombo.setSelectedIndex(0); // Default to the first value
    col.setCellEditor(Application.getWidgetFactory().createCellEditor(deleteRulesCombo));

    tablePreferences.bind(table, null, null, null, ObjRelationshipTableModel.REL_NAME, true);
}

From source file:org.apache.cayenne.modeler.editor.ObjEntityRelationshipTab.java

protected void rebuildTable(ObjEntity entity) {
    final ObjRelationshipTableModel model = new ObjRelationshipTableModel(entity, mediator, this);

    model.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            if (table.getSelectedRow() >= 0) {
                ObjRelationship rel = model.getRelationship(table.getSelectedRow());
                if (((ObjEntity) rel.getSourceEntity()).getDbEntity() != null) {
                    resolve.setEnabled(true);
                } else
                    resolve.setEnabled(false);

                resolveMenu.setEnabled(resolve.isEnabled());
            }//from   w  ww  .  j  a  v  a  2s .  c om
        }
    });

    table.setModel(model);
    table.setRowHeight(25);
    table.setRowMargin(3);

    TableColumn col = table.getColumnModel().getColumn(ObjRelationshipTableModel.REL_TARGET);
    JComboBox targetCombo = Application.getWidgetFactory().createComboBox(createObjEntityComboModel(), false);
    AutoCompletion.enable(targetCombo);

    targetCombo.setRenderer(CellRenderers.entityListRendererWithIcons(entity.getDataMap()));
    targetCombo.setSelectedIndex(-1);
    col.setCellEditor(Application.getWidgetFactory().createCellEditor(targetCombo));

    col = table.getColumnModel().getColumn(ObjRelationshipTableModel.REL_DELETERULE);
    JComboBox deleteRulesCombo = Application.getWidgetFactory().createComboBox(deleteRules, false);
    deleteRulesCombo.setEditable(false);
    deleteRulesCombo.setSelectedIndex(0); // Default to the first value
    col.setCellEditor(Application.getWidgetFactory().createCellEditor(deleteRulesCombo));

    tablePreferences.bind(table, null, null, null, ObjRelationshipTableModel.REL_NAME, true);
}

From source file:org.dc.file.search.ui.DashboardForm.java

private void initCommentResultsTable() {
    txtCommentThread.setText("");
    Object[][] initData = {};//from ww  w . j a  va  2 s.  c  o m
    DefaultTableModel commentModel = new DefaultTableModel(initData, commentColumnNames);
    tblComments.setModel(commentModel);
    tblComments.setRowHeight(32);

    TableColumn commentRatingColumn = tblComments.getColumnModel().getColumn(COMMENT_RATING_COL_INDEX);
    commentRatingColumn.setCellRenderer(new StarRatingsRenderer(tblComments, StarRatingsType.COMMENT));
    commentRatingColumn.setCellEditor(new StarRatingsEditor(tblComments, StarRatingsType.COMMENT));
    commentRatingColumn.setPreferredWidth(30);

    TableColumn commentReply = tblComments.getColumnModel().getColumn(COMMENT_REPLY_COL_INDEX);
    commentReply.setCellRenderer(new ButtonRenderer(tblComments));
    commentReply.setCellEditor(new ButtonEditor(tblComments));

    tblComments.getSelectionModel().addListSelectionListener(event -> {
        if (tblComments.getSelectedRow() >= 0) {
            txtCommentThread.setText("");
            DFile dFile = resultFiles.get(selectedFile);
            String commentId = tblComments.getValueAt(tblComments.getSelectedRow(), 0).toString();
            Comment parentComment = null;
            List<Comment> comments = dFile.getComments();
            for (Comment c : comments) {
                if (c.getCommentId().equals(commentId)) {
                    parentComment = c;
                    break;
                }
            }
            if (parentComment == null) {
                return;
            }
            StringBuilder stringBuilder = new StringBuilder();
            for (Comment replyComment : parentComment.getReplies()) {
                stringBuilder.append(replyComment.getUserName());
                stringBuilder.append(": ");
                stringBuilder.append(replyComment.getText());
                stringBuilder.append("\n----------------------------------\n");
            }
            txtCommentThread.setText(stringBuilder.toString());
        }
    });
}

From source file:org.dc.file.search.ui.DashboardForm.java

private void initSearchResultsTable() {
    Object[][] initData = {};/*  w w  w  .  j  av  a  2 s . com*/
    DefaultTableModel searchModel = new DefaultTableModel(initData, searchColumnNames);
    tblSearchResults.setModel(searchModel);
    tblSearchResults.setRowHeight(32);

    tblSearchResults.getColumnModel().getColumn(PEER_COL_INDEX).setPreferredWidth(30);
    tblSearchResults.getColumnModel().getColumn(HOP_COUNT_COL_INDEX).setPreferredWidth(20);
    tblSearchResults.getColumnModel().getColumn(FILE_COL_INDEX).setPreferredWidth(20);

    TableColumn starRatingsColumn = tblSearchResults.getColumnModel().getColumn(STAR_RATINGS_COL_INDEX);
    starRatingsColumn.setCellRenderer(new StarRatingsRenderer(tblSearchResults, StarRatingsType.FILE));
    starRatingsColumn.setCellEditor(new StarRatingsEditor(tblSearchResults, StarRatingsType.FILE));
    starRatingsColumn.setPreferredWidth(30);

    tblSearchResults.getSelectionModel().addListSelectionListener(event -> {
        if (tblSearchResults.getSelectedRow() >= 0) {
            updateCommentTable();
        }
    });
}

From source file:org.ecoinformatics.seek.ecogrid.ServicesDisplayPanel.java

private void init() {
    this.setPreferredSize(new Dimension(HEADNAME.length * CELLPREFERREDWIDTH, CELLHEIGHT));
    this.getViewport().setBackground(Color.WHITE);

    tableModel = new ServicesDisplayTableModel(selectedServiceList, HEADNAME);

    table = new JTable(tableModel);
    table.setRowSelectionAllowed(ROWSELECTION);
    table.setColumnSelectionAllowed(COLUMNSELECTION);
    table.setCellSelectionEnabled(CELLSELECTION);

    Vector rowHeightFactorList = tableModel.getRowHeightFactor();
    initRowHeight(rowHeightFactorList);// w  ww  .ja v  a2 s. co  m
    initColumnWidth();

    // first col(service name render use checkbox renderer
    // second col(location) use default rendered
    // third col(doctype) use table rendered
    checkBoxRenderer = new CheckBoxTableCellRenderer(table, selectedServiceList,
            CheckBoxTableCellRenderer.DEFAUTTOPROW);
    tableRenderer = new TableTableCellRenderer(table, selectedServiceList);

    TableColumn serviceNameCol = table.getColumn(SERVICENAMECOL);
    serviceNameCol.setCellRenderer(checkBoxRenderer);
    serviceNameCol.setCellEditor(new CheckBoxTableCellEditor(table, new JCheckBox(), selectedServiceList,
            CheckBoxTableCellRenderer.DEFAUTTOPROW));

    TableColumn docTypeCol = table.getColumn(DOCUMENTTYPECOL);
    docTypeCol.setCellRenderer(tableRenderer);
    docTypeCol.setCellEditor(new TableTableCellEditor(table, new JCheckBox(), selectedServiceList));

    this.getViewport().add(table);
}