Example usage for javax.swing.table TableColumn setPreferredWidth

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

Introduction

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

Prototype

@BeanProperty(description = "The preferred width of the column.")
public void setPreferredWidth(int preferredWidth) 

Source Link

Document

Sets this column's preferred width to preferredWidth.

Usage

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

/**
 * @param table//from   www .  j  av  a2s .co  m
 * @param model
 */
protected void autoResizeColWidth(final JTable table, final DefaultTableModel model) {
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setModel(model);

    int margin = 5;

    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();

    int preferredWidthTotal = 0;
    int renderedWidthTotal = 0;
    int[] colWidths = new int[table.getColumnCount()];
    int[] strWidths = new int[table.getColumnCount()];
    for (int i = 0; i < table.getColumnCount(); i++) {
        int vColIndex = i;
        TableColumn col = colModel.getColumn(vColIndex);
        int width = 0;

        TableCellRenderer headerRenderer = col.getHeaderRenderer();
        if (headerRenderer instanceof JLabel) {
            ((JLabel) headerRenderer).setHorizontalAlignment(SwingConstants.CENTER);
        }

        // Get width of column header
        TableCellRenderer renderer = col.getCellRenderer();
        if (renderer == null) {
            renderer = table.getTableHeader().getDefaultRenderer();
        }

        Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0,
                0);

        width = comp.getPreferredSize().width;

        // Get maximum width of column data
        int strWidth = 0;
        boolean isString = model.getColumnClass(i) == String.class;
        for (int r = 0; r < table.getRowCount(); r++) {
            renderer = table.getCellRenderer(r, vColIndex);
            Object objVal = table.getValueAt(r, vColIndex);
            if (isString && objVal != null) {
                strWidth = Math.max(strWidth, ((String) objVal).length());
            }
            comp = renderer.getTableCellRendererComponent(table, objVal, false, false, r, vColIndex);
            width = Math.max(width, comp.getPreferredSize().width);
        }

        // Add margin
        width += 2 * margin;

        preferredWidthTotal += col.getPreferredWidth();
        colWidths[i] = width;
        strWidths[i] = strWidth;

        renderedWidthTotal += width;
    }

    if (renderedWidthTotal > preferredWidthTotal) {
        for (int i = 0; i < table.getColumnCount(); i++) {
            TableColumn col = colModel.getColumn(i);
            TableCellRenderer renderer = col.getCellRenderer();
            if (renderer != null) {
                ((JLabel) renderer).setHorizontalAlignment(
                        strWidths[i] > 20 ? SwingConstants.LEFT : SwingConstants.CENTER);
                //((JLabel)renderer).setHorizontalAlignment(SwingConstants.LEFT);
            }

            if (model.getColumnCount() > 3 && renderedWidthTotal > preferredWidthTotal) {
                col.setPreferredWidth(colWidths[i]);
            }
        }
    }

    ((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer())
            .setHorizontalAlignment(SwingConstants.LEFT);

    // table.setAutoCreateRowSorter(true);
    table.getTableHeader().setReorderingAllowed(false);
}

From source file:edu.ku.brc.af.ui.forms.TableViewObj.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  ww .  j a  v a2 s . c  om
private void initColumnSizes(final JTable tableArg) {
    ColTableModel tblModel = (ColTableModel) tableArg.getModel();
    TableColumn column = null;
    Component comp = null;
    int headerWidth = 0;
    int cellWidth = 0;

    TableCellRenderer headerRenderer = tableArg.getTableHeader().getDefaultRenderer();

    for (int i = 0; i < tblModel.getColumnCount(); i++) {
        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;

        /*
        if (DEBUG) {
        System.out.println("Initializing width of column "
                           + i + ". "
                           + "headerWidth = " + headerWidth
                           + "; cellWidth = " + cellWidth);
        }*/

        //XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
        column.setPreferredWidth(Math.max(headerWidth, cellWidth));
    }
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Calculates and sets the each column to it preferred size.  NOTE: This
 * method also sets the table height to 10 rows.
 * //from   w  ww  .jav  a 2 s  . co m
 * @param table the table to fix up
 * @param numRowsHeight the number of rows to make the table height (or null not to set it)
 */
public static void calcColumnWidths(final JTable table, final Integer numRowsHeight, final Integer maxWidth) {
    if (table != null) {
        JTableHeader header = table.getTableHeader();

        TableCellRenderer defaultHeaderRenderer = null;

        if (header != null) {
            defaultHeaderRenderer = header.getDefaultRenderer();
        }

        TableColumnModel columns = table.getColumnModel();
        TableModel data = table.getModel();

        int margin = columns.getColumnMargin(); // only JDK1.3

        int rowCount = data.getRowCount();

        int totalWidth = 0;

        for (int i = columns.getColumnCount() - 1; i >= 0; --i) {
            TableColumn column = columns.getColumn(i);

            int columnIndex = column.getModelIndex();

            int width = -1;

            TableCellRenderer h = column.getHeaderRenderer();

            if (h == null)
                h = defaultHeaderRenderer;

            if (h != null) // Not explicitly impossible
            {
                Component c = h.getTableCellRendererComponent(table, column.getHeaderValue(), false, false, -1,
                        i);

                width = c.getPreferredSize().width;
            }

            for (int row = rowCount - 1; row >= 0; --row) {
                TableCellRenderer r = table.getCellRenderer(row, i);

                Component c = r.getTableCellRendererComponent(table, data.getValueAt(row, columnIndex), false,
                        false, row, i);

                width = Math.max(width, c.getPreferredSize().width + 10); // adding an arbitray 10 pixels to make it look nicer

                if (maxWidth != null) {
                    width = Math.min(width, maxWidth);
                }
            }

            if (width >= 0) {
                column.setPreferredWidth(width + margin); // <1.3: without margin
            } else {
                // ???
            }

            totalWidth += column.getPreferredWidth();
        }

        // If you like; This does not make sense for two many columns!
        Dimension size = table.getPreferredScrollableViewportSize();
        //if (totalWidth > size.width)
        {
            if (numRowsHeight != null) {
                size.height = Math.min(size.height, table.getRowHeight() * numRowsHeight);
            }
            size.width = totalWidth;
            table.setPreferredScrollableViewportSize(size);
        }
    }
}

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 {/*from   ww  w  .j ava  2  s .  c om*/
        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.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  ww.  j  av a2s . 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:net.sourceforge.pmd.cpd.GUI.java

private void setListDataFrom(List<Match> matches) {

    resultsTable.setModel(tableModelFrom(matches));

    TableColumnModel colModel = resultsTable.getColumnModel();
    TableColumn column;
    int width;// w  w  w . j a  v a2s. c om

    for (int i = 0; i < matchColumns.length; i++) {
        if (matchColumns[i].width() > 0) {
            column = colModel.getColumn(i);
            width = matchColumns[i].width();
            column.setPreferredWidth(width);
            column.setMinWidth(width);
            column.setMaxWidth(width);
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.bulkupload.BulkUploadPresenter.java

private void setupColumns() {
    final TableRenderer renderer = new TableRenderer();
    final int width = 50;
    for (int i = 0; i < theJobListTable.getColumnCount(); i++) {
        final TableColumn col = theJobListTable.getColumnModel().getColumn(i);
        col.setCellRenderer(renderer);/* w  w  w .  jav  a  2s.c  o m*/
        col.setResizable(true);
        if (i < (theJobListTable.getColumnCount() - 1)) {
            col.setPreferredWidth(width);
            col.setWidth(width);
        }
    }
}

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

@SuppressWarnings("serial")
private void formWindowOpened(java.awt.event.WindowEvent evt) { // NOPMD
    try {/*from  w  w  w .  ja  va2  s .c o  m*/
        theFormControl = new FormControl(this, theSettingsPath);
    } catch (Exception ex) {
        LOG.error("Error loading form parameters", ex);
    }
    if (theFormControl != null) {
        final Action updateDividersAction = new AbstractAction() {
            public void actionPerformed(final ActionEvent e) {
                Timer t = (Timer) e.getSource();
                t.stop();
                splitMain.setDividerLocation(theFormControl.getExtra(SPLIT_NAME, 320));
                splitMain.repaint();
                for (int i = 0; i < tblResults.getColumnModel().getColumnCount(); i++) {
                    TableColumn col = tblResults.getColumnModel().getColumn(i);
                    String colName = "Col" + i;
                    int width = theFormControl.getExtra(colName, 150);
                    col.setPreferredWidth(width);
                    col.setWidth(width);
                }
            }
        };
        new Timer(200, updateDividersAction).start();
    }
    thePresenter.showResults();
}

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

@SuppressWarnings("serial")
public void setupScreen(final AppProperties appProperties, final String settingsPath) throws Exception {
    LOG.debug("setupScreen");
    this.setJMenuBar(mnuMain);
    theSettingsPath = settingsPath;//from  w w  w .  jav  a 2s  .  c  o  m
    LOG.debug("setupScreen, setting provenance event presenter");
    theAppProperties = appProperties;
    theUserGroupData = theAppProperties.getUserData().getUser(theAppProperties.getLoggedOnUser())
            .getUserGroupData();
    final boolean searchVisible = (theUserGroupData.isIncludeCMS2Search()
            || theUserGroupData.isIncludeCMS1Search() || theUserGroupData.isIncludeProducerList()
            || theUserGroupData.isIncludeNoCMSOption());
    pnlCmsReference.setVisible(searchVisible);
    mnuViewShowSearch.setVisible(searchVisible);
    if (theUserGroupData.isIncludeCMS2Search()) {
        rbnCMS2.setSelected(true);
    } else if (theUserGroupData.isIncludeCMS1Search()) {
        rbnCMS1.setSelected(true);
    } else if (theUserGroupData.isIncludeProducerList()) {
        rbnStaffMediated.setSelected(true);
    } else if (theUserGroupData.isIncludeNoCMSOption()) {
        rbnNoCmsRef.setSelected(true);
    }
    rbnCMS2.setVisible(theUserGroupData.isIncludeCMS2Search());
    rbnCMS1.setVisible(theUserGroupData.isIncludeCMS1Search());
    rbnNoCmsRef.setVisible(theUserGroupData.isIncludeNoCMSOption());
    rbnStaffMediated.setVisible(theUserGroupData.isIncludeProducerList());
    rbnCMS1.setText(theAppProperties.getApplicationData().getCMS1Label());
    rbnCMS2.setText(theAppProperties.getApplicationData().getCMS2Label());
    if (theUserGroupData.isIncludeCMS2Search()) {
        rbnCMS2.setSelected(true);
    } else {
        if (theUserGroupData.isIncludeCMS1Search()) {
            rbnCMS1.setSelected(true);
        } else {
            rbnNoCmsRef.setSelected(true);
        }
    }
    setTitle(title + theAppProperties.getAppVersion());
    ClassLoader cLoader = Thread.currentThread().getContextClassLoader();
    java.net.URL imageURL = cLoader.getResource("Indigo_logo_64x64.jpg");
    setIconImage(Toolkit.getDefaultToolkit().getImage(imageURL));
    LOG.debug("setupScreen, setting FormControl");
    try {
        theFormControl = new FormControl(this, theSettingsPath);
        fixBackwardsCompatibility();
    } catch (Exception ex) {
        LOG.error("Error loading form parameters", ex);
    }
    LOG.debug("setupScreen, adding handlers");
    depositPresenter.addHandlers(treeFileSystem, treeEntities, treeStructMap, cmbSelectTemplate,
            cmbSelectStructTemplate, cmbSortBy, cmbFixityType, tblDetail, tblJobQueueRunning,
            tblJobQueuePending, tblJobQueueFailed, tblJobQueueDeposited, tblJobQueueComplete, mnuFileFavourites,
            lstProducers, lstMaterialFlow);
    LOG.debug("setupScreen, handlers added");
    checkButtons();
    setCMSDetails();
    setHotKeyVisibility();
    depositPresenter.checkForInitialLoadScreenSizes(theFormControl, splitAddIE, SPLIT_IE_ATTR, splitMain,
            SPLIT_MAIN_ATTR, splitMainDetail, SPLIT_MAIN_DETAIL_ATTR, splitMainRight, SPLIT_MAIN_RIGHT_ATTR);
    final Action updateDividersAction = new AbstractAction() {
        public void actionPerformed(final ActionEvent e) {
            Timer t = (Timer) e.getSource();
            t.stop();
            splitAddIE.setDividerLocation(theFormControl.getExtra(SPLIT_IE_ATTR, 175));
            splitMain.setDividerLocation(theFormControl.getExtra(SPLIT_MAIN_ATTR, 200));
            splitMainDetail.setDividerLocation(theFormControl.getExtra(SPLIT_MAIN_DETAIL_ATTR, 200));
            splitMainRight.setDividerLocation(theFormControl.getExtra(SPLIT_MAIN_RIGHT_ATTR, 200));
            splitMain.repaint();
            splitMainDetail.repaint();
            splitMainRight.repaint();
            TableColumn col = tblDetail.getColumnModel().getColumn(0);
            col.setPreferredWidth(theFormControl.getExtra(META_DATA_COL_1_ATTR, 200));
            col = tblDetail.getColumnModel().getColumn(1);
            col.setPreferredWidth(theFormControl.getExtra(META_DATA_COL_2_ATTR, 200));

            MultiSplitLayout layout = mspJobQueue.getMultiSplitLayout();
            layout.setFloatingDividers(false);
            MultiSplitLayout.Split model = (MultiSplitLayout.Split) layout.getModel();
            MultiSplitLayout.Divider divider = (MultiSplitLayout.Divider) model.getChildren().get(1);
            Rectangle bounds = divider.getBounds();
            int top = theFormControl.getExtra(JOB_QUEUE_DIVIDER_1_ATTR, bounds.y);
            bounds.y = top;
            divider.setBounds(bounds);
            theOldHeight1 = top;

            divider = (MultiSplitLayout.Divider) model.getChildren().get(3);
            bounds = divider.getBounds();
            top = theFormControl.getExtra(JOB_QUEUE_DIVIDER_2_ATTR, bounds.y);
            bounds.y = top;
            divider.setBounds(bounds);
            theOldHeight2 = top;

            divider = (MultiSplitLayout.Divider) model.getChildren().get(5);
            bounds = divider.getBounds();
            top = theFormControl.getExtra(JOB_QUEUE_DIVIDER_3_ATTR, bounds.y);
            bounds.y = top;
            divider.setBounds(bounds);
            theOldHeight3 = top;

            divider = (MultiSplitLayout.Divider) model.getChildren().get(7);
            bounds = divider.getBounds();
            top = theFormControl.getExtra(JOB_QUEUE_DIVIDER_4_ATTR, bounds.y);
            bounds.y = top;
            divider.setBounds(bounds);
            theOldHeight4 = top;
        }
    };
    new Timer(200, updateDividersAction).start();
    final PersonalSettings personalSettings = theAppProperties.getApplicationData().getPersonalSettings();
    theStandardFont = personalSettings.getStandardFont();
    final SortBy sortBy = personalSettings.getSortFilesBy();
    for (int i = 0; i < cmbSortBy.getItemCount(); i++) {
        final SortBy item = (SortBy) cmbSortBy.getItemAt(i);
        if (item.equals(sortBy)) {
            cmbSortBy.setSelectedIndex(i);
            break;
        }
    }
    setJobQueuePanes();
    LOG.debug("setupScreen, end");
    addHotKeyListener(this);
}

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

private void setJobQueueTableDefaults(JTable jobQueueTable, JobQueueTableModel jobQueueTableModel) {
    jobQueueTableModel.addTableModelListener(new JobQueueTableModelListener());
    jobQueueTable.setModel(jobQueueTableModel);
    jobQueueTable.setSurrendersFocusOnKeystroke(true);
    jobQueueTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    jobQueueTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    jobQueueTable.setColumnSelectionAllowed(true);
    jobQueueTable.setRowSelectionAllowed(true);
    TableRenderer renderer = new TableRenderer();
    TableColumn col = jobQueueTable.getColumnModel().getColumn(0);
    int width = 200;
    col.setPreferredWidth(width);
    col.setWidth(width);//from ww w.java  2  s  .co  m
    col.setCellRenderer(renderer);

    col = jobQueueTable.getColumnModel().getColumn(1);
    width = 1400;
    col.setPreferredWidth(width);
    col.setWidth(width);
    col.setCellRenderer(renderer);
}