Example usage for javax.swing.table TableColumnModel getColumn

List of usage examples for javax.swing.table TableColumnModel getColumn

Introduction

In this page you can find the example usage for javax.swing.table TableColumnModel getColumn.

Prototype

public TableColumn getColumn(int columnIndex);

Source Link

Document

Returns the TableColumn object for the column at columnIndex.

Usage

From source file:edu.ucla.stat.SOCR.chart.SuperPieChart.java

public void setDataTable(String input) {

    StringTokenizer lnTkns = new StringTokenizer(input, "#");
    String line;//from  w ww . j  a v a  2  s.co m
    int lineCt = lnTkns.countTokens();
    resetTableRows(lineCt);
    int r = 0;
    while (lnTkns.hasMoreTokens()) {
        line = lnTkns.nextToken();

        //   String tb[] =line.split("\t");
        StringTokenizer cellTkns = new StringTokenizer(line, " \t\f,");// IE use "space" Mac use tab as cell separator
        int cellCnt = cellTkns.countTokens();
        String tb[] = new String[cellCnt];
        int r1 = 0;
        while (cellTkns.hasMoreTokens()) {
            tb[r1] = cellTkns.nextToken();
            r1++;
        }
        //System.out.println("tb.length="+tb.length);
        int colCt = tb.length;
        resetTableColumns(colCt);
        for (int i = 0; i < tb.length; i++) {
            //System.out.println(tb[i]);
            if (tb[i].length() == 0)
                tb[i] = "0";
            dataTable.setValueAt(tb[i], r, i);
        }
        r++;
    }

    TableColumnModel columnModel = dataTable.getColumnModel();
    columnModel.getColumn(0).setHeaderValue("Name");
    columnModel.getColumn(1).setHeaderValue("Value");
    columnModel.getColumn(2).setHeaderValue("pullout flag");
    // this will update the mapping panel     
    resetTableColumns(dataTable.getColumnCount());
}

From source file:com.diversityarrays.kdxplore.curate.TraitsAndInstancesPanel2.java

public TraitsAndInstancesPanel2(CurationContext cc, Font smallFont, TIStatsTableModel tistm,
        boolean anyInstanceNumbers, int nInvalidRules, String tAndIpanelLabel,
        CurationMenuProvider curationMenuProvider, Consumer<List<OutlierSelection>> outlierConsumer) {
    super(new BorderLayout());

    this.curationContext = cc;
    this.outlierConsumer = outlierConsumer;
    this.curationMenuProvider = curationMenuProvider;

    this.tiStatsModel = tistm;

    curationContext.addPropertyChangeListener(propertyChangeListener);

    traitInstanceStatsTable = new TraitInstanceStatsTable(tiStatsModel);

    traitInstanceStatsTable.addPropertyChangeListener("rowSorter", rowSorterChangeListener);
    traitInstanceStatsTable.setAutoCreateRowSorter(true);

    traitInstanceStatsTable.addMouseListener(new MouseAdapter() {
        @Override//w  w w . j  a v a2s .  c o m
        public void mouseClicked(MouseEvent me) {
            int clickCount = me.getClickCount();

            if (SwingUtilities.isRightMouseButton(me) && 1 == clickCount) {
                me.consume();
                showContextMenu(me);
            } else if (SwingUtilities.isLeftMouseButton(me) && 2 == clickCount) {
                showTraitInstanceInfo(me);
            }
        }
    });

    Map<String, TableColumn[]> tableColumnsByChoice = createInstanceTableColumnsByChoice();
    TableColumnSelectionButton tcsb = new TableColumnSelectionButton(traitInstanceStatsTable,
            tableColumnsByChoice);

    StringCellRenderer scRenderer = new StringCellRenderer();
    scRenderer.setHorizontalAlignment(SwingConstants.CENTER);

    statDetailRenderer.setHorizontalAlignment(SwingConstants.CENTER);

    traitInstanceStatsTable.setDefaultRenderer(String.class, scRenderer);
    Transformer<TraitInstance, String> instanceNameTransformer = new Transformer<TraitInstance, String>() {
        @Override
        public String transform(TraitInstance ti) {
            return curationContext.makeTraitInstanceName(ti);
        }
    };
    TraitInstanceCellRenderer tiRenderer = new TraitInstanceCellRenderer(
            curationContext.getTraitColorProvider(), instanceNameTransformer);
    tiRenderer.setName("FOR-STATS-TABLE"); //$NON-NLS-1$
    traitInstanceStatsTable.setDefaultRenderer(TraitInstance.class, tiRenderer);
    traitInstanceStatsTable.setDefaultRenderer(Comparable.class, statDetailRenderer);

    TableColumnModel tcm = traitInstanceStatsTable.getColumnModel();
    Integer viewColumnIndex = tistm.getViewColumnIndex();
    if (viewColumnIndex != null) {
        TableColumn viewColumn = tcm.getColumn(viewColumnIndex);
        viewColumn.setMaxWidth(40);
        viewColumn.setCellRenderer(new OptionalCheckboxRenderer("No Values"));
    }

    if (nInvalidRules <= 0) {
        // Hide that column!
        int columnIndex = tistm.getValRuleErrorColumnIndex();
        columnIndex = traitInstanceStatsTable.convertColumnIndexToView(columnIndex);
        if (columnIndex >= 0) {
            TableColumn c = tcm.getColumn(columnIndex);
            tcm.removeColumn(c);
        }
    }

    TableColumn dataTypeTableColumn = traitInstanceStatsTable.getColumnModel()
            .getColumn(tistm.getTraitInstanceDatatypeColumnIndex());
    dataTypeTableColumn.setCellRenderer(new TraitDataTypeRenderer());

    Function<JTable, JScrollPane> scrollMaker = new Function<JTable, JScrollPane>() {
        @Override
        public JScrollPane apply(JTable t) {
            return new PromptScrollPane(t, "Select Trait in the Panel: " + tAndIpanelLabel);
        }
    };
    TitledTablePanelWithResizeControls ttp = new TitledTablePanelWithResizeControls("Trait Instances",
            traitInstanceStatsTable, smallFont, scrollMaker);
    ttp.scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    ttp.scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, tcsb);

    new CurationContextOptionsPopup(curationContext, ttp.separator);

    if (anyInstanceNumbers) {
        tcsb.setSelectedColumns(SimpleStatistics.GROUP_BASIC_STATS);
    } else {
        Set<Object> headerValues = new HashSet<>();
        for (TableColumn tc : tableColumnsByChoice.get(SimpleStatistics.GROUP_BASIC_STATS)) {
            headerValues.add(tc.getHeaderValue());
        }
        headerValues.remove(tistm.getInstanceHeading());
        tcsb.initialiseSelectedColumns(new Predicate<Object>() {
            @Override
            public boolean evaluate(Object hvalue) {
                return headerValues.contains(hvalue);
            }
        });
    }

    add(ttp, BorderLayout.CENTER);
}

From source file:edu.ucla.stat.SOCR.chart.SuperHistogramChart.java

public void setXLabel(String xLabel) {
    domainLabel = xLabel;/*from  w w w  . j a  v a 2  s  . c  om*/
    TableColumnModel columnModel = dataTable.getColumnModel();
    for (int i = 0; i < columnModel.getColumnCount(); i += 2)
        columnModel.getColumn(i).setHeaderValue(xLabel);
    dataTable.setTableHeader(new EditableHeader(columnModel));
}

From source file:net.sf.jabref.openoffice.StyleSelectDialog.java

private void init(String inSelection) {
    this.initSelection = inSelection;

    ButtonGroup bg = new ButtonGroup();
    bg.add(useDefaultAuthoryear);/*from w  w  w.  jav  a  2 s  .  co m*/
    bg.add(useDefaultNumerical);
    bg.add(chooseDirectly);
    bg.add(setDirectory);
    if (Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE)) {
        useDefaultAuthoryear.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE)) {
        useDefaultNumerical.setSelected(true);
    } else {
        if (Globals.prefs.getBoolean(JabRefPreferences.OO_CHOOSE_STYLE_DIRECTLY)) {
            chooseDirectly.setSelected(true);
        } else {
            setDirectory.setSelected(true);
        }
    }

    directFile.setText(Globals.prefs.get(JabRefPreferences.OO_DIRECT_FILE));
    styleDir.setText(Globals.prefs.get(JabRefPreferences.OO_STYLE_DIRECTORY));
    directFile.setEditable(false);
    styleDir.setEditable(false);

    popup.add(edit);

    BrowseAction dfBrowse = BrowseAction.buildForFile(directFile, directFile);
    browseDirectFile.addActionListener(dfBrowse);

    BrowseAction sdBrowse = BrowseAction.buildForDir(styleDir, setDirectory);
    browseStyleDir.addActionListener(sdBrowse);

    showDefaultAuthoryearStyle.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            displayDefaultStyle(true);
        }
    });
    showDefaultNumericalStyle.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            displayDefaultStyle(false);
        }
    });
    // Add action listener to "Edit" menu item, which is supposed to open the style file in an external editor:
    edit.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            int i = table.getSelectedRow();
            if (i == -1) {
                return;
            }
            ExternalFileType type = ExternalFileTypes.getInstance().getExternalFileTypeByExt("jstyle");
            String link = tableModel.getElementAt(i).getFile().getPath();
            try {
                if (type == null) {
                    JabRefDesktop.openExternalFileUnknown(frame, new BibEntry(), new MetaData(), link,
                            new UnknownExternalFileType("jstyle"));
                } else {
                    JabRefDesktop.openExternalFileAnyFormat(new MetaData(), link, type);
                }
            } catch (IOException e) {
                LOGGER.warn("Problem open style file editor", e);
            }
        }
    });

    diag = new JDialog(frame, Localization.lang("Styles"), true);

    styles = new BasicEventList<>();
    EventList<OOBibStyle> sortedStyles = new SortedList<>(styles);

    // Create a preview panel for previewing styles:
    preview = new PreviewPanel(null, new MetaData(), "");
    // Use the test entry from the Preview settings tab in Preferences:
    preview.setEntry(prevEntry);

    tableModel = (DefaultEventTableModel<OOBibStyle>) GlazedListsSwing
            .eventTableModelWithThreadProxyList(sortedStyles, new StyleTableFormat());
    table = new JTable(tableModel);
    TableColumnModel cm = table.getColumnModel();
    cm.getColumn(0).setPreferredWidth(100);
    cm.getColumn(1).setPreferredWidth(200);
    cm.getColumn(2).setPreferredWidth(80);
    selectionModel = (DefaultEventSelectionModel<OOBibStyle>) GlazedListsSwing
            .eventSelectionModelWithThreadProxyList(sortedStyles);
    table.setSelectionModel(selectionModel);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            if (mouseEvent.isPopupTrigger()) {
                tablePopup(mouseEvent);
            }
        }

        @Override
        public void mouseReleased(MouseEvent mouseEvent) {
            if (mouseEvent.isPopupTrigger()) {
                tablePopup(mouseEvent);
            }
        }
    });

    selectionModel.getSelected().addListEventListener(new EntrySelectionListener());

    styleDir.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            readStyles();
            setDirectory.setSelected(true);
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
            readStyles();
            setDirectory.setSelected(true);
        }

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
            readStyles();
            setDirectory.setSelected(true);
        }
    });
    directFile.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            chooseDirectly.setSelected(true);
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
            chooseDirectly.setSelected(true);
        }

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
            chooseDirectly.setSelected(true);
        }
    });

    contentPane.setTopComponent(new JScrollPane(table));
    contentPane.setBottomComponent(preview);

    readStyles();

    DefaultFormBuilder b = new DefaultFormBuilder(
            new FormLayout("fill:pref,4dlu,fill:150dlu,4dlu,fill:pref", ""));
    b.append(useDefaultAuthoryear, 3);
    b.append(showDefaultAuthoryearStyle);
    b.nextLine();
    b.append(useDefaultNumerical, 3);
    b.append(showDefaultNumericalStyle);
    b.nextLine();
    b.append(chooseDirectly);
    b.append(directFile);
    b.append(browseDirectFile);
    b.nextLine();
    b.append(setDirectory);
    b.append(styleDir);
    b.append(browseStyleDir);
    b.nextLine();
    DefaultFormBuilder b2 = new DefaultFormBuilder(
            new FormLayout("fill:1dlu:grow", "fill:pref, fill:pref, fill:270dlu:grow"));

    b2.nextLine();
    b2.append(new JLabel("<html>"
            + Localization.lang("This is the list of available styles. Select the one you want to use.")
            + "</html>"));
    b2.nextLine();
    b2.append(contentPane);
    b.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    b2.getPanel().setBorder(BorderFactory.createEmptyBorder(15, 5, 5, 5));
    diag.add(b.getPanel(), BorderLayout.NORTH);
    diag.add(b2.getPanel(), BorderLayout.CENTER);

    AbstractAction okListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if (!useDefaultAuthoryear.isSelected() && !useDefaultNumerical.isSelected()) {
                if (chooseDirectly.isSelected()) {
                    File f = new File(directFile.getText());
                    if (!f.exists()) {
                        JOptionPane.showMessageDialog(diag,
                                Localization.lang(
                                        "You must select either a valid style file, or use a default style."),
                                Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                } else {
                    if ((table.getRowCount() == 0) || (table.getSelectedRowCount() == 0)) {
                        JOptionPane.showMessageDialog(diag,
                                Localization.lang(
                                        "You must select either a valid style file, or use a default style."),
                                Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                }
            }
            okPressed = true;
            storeSettings();
            diag.dispose();
        }
    };
    ok.addActionListener(okListener);

    Action cancelListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            diag.dispose();
        }
    };
    cancel.addActionListener(cancelListener);

    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    diag.add(bb.getPanel(), BorderLayout.SOUTH);

    ActionMap am = bb.getPanel().getActionMap();
    InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelListener);
    im.put(KeyStroke.getKeyStroke("ENTER"), "enterOk");
    am.put("enterOk", okListener);

    diag.pack();
    diag.setLocationRelativeTo(frame);
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            contentPane.setDividerLocation(contentPane.getSize().height - 150);
        }
    });

}

From source file:com.projity.pm.graphic.spreadsheet.SpreadSheet.java

public void createDefaultColumnsFromModel(ArrayList fieldArray) {
    // Remove any current columns
    TableColumnModel cm = getColumnModel();
    while (cm.getColumnCount() > 0) {
        cm.removeColumn(cm.getColumn(0));
    }/*from   www . ja  v  a 2s  .  co  m*/

    // Create new columns from the data model info
    int colCount = fieldArray.size();
    for (int i = 0; i < colCount; i++) {
        TableColumn newColumn = new TableColumn(i);
        addColumn(newColumn);
    }

    //      TableModel m = getModel();
    //      if (m != null) {
    //         // Remove any current columns
    //         TableColumnModel cm = getColumnModel();
    //         while (cm.getColumnCount() > 0) {
    //            cm.removeColumn(cm.getColumn(0));
    //         }
    //
    //         // Create new columns from the data model info
    //         for (int i = 0; i < m.getColumnCount(); i++) {
    //            TableColumn newColumn = new TableColumn(i);
    //            addColumn(newColumn);
    //         }
    //      }
}

From source file:com.qspin.qtaste.ui.xmleditor.TestRequirementEditor.java

private void computeColumnWidths() {
    // horizontal spacing
    int hspace = 6;
    TableModel model = m_TestRequirementTable.getModel();

    // rows no// www  .j ava2s . c  om
    int cols = model.getColumnCount();

    // columns no
    int rows = model.getRowCount();

    // width vector
    int w[] = new int[model.getColumnCount()];

    // computes headers widths
    for (int i = 0; i < cols; i++) {
        w[i] = (int) m_TestRequirementTable
                .getDefaultRenderer(String.class).getTableCellRendererComponent(m_TestRequirementTable,
                        m_TestRequirementModel.getColumnName(i), false, false, -1, i)
                .getPreferredSize().getWidth() + hspace;
        TableColumn hcol = m_TestRequirementTable.getColumn(m_TestRequirementModel.getColumnName(i));
        hcol.setHeaderRenderer(new MyTableHeaderRenderer());

    }

    // check if cell values fit in their cells and if not
    // keep in w[i] the necessary with
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            Object o = model.getValueAt(i, j);
            int width = 0;
            if (o != null) {
                width = (int) m_TestRequirementTable.getCellRenderer(i, j)
                        .getTableCellRendererComponent(m_TestRequirementTable, o, false, false, i, j)
                        .getPreferredSize().getWidth() + hspace;
            }
            if (w[j] < width) {
                w[j] = width;
            }
        }
    }

    TableColumnModel colModel = m_TestRequirementTable.getColumnModel();

    // and finally setting the column widths
    for (int i = 0; i < cols; i++) {
        colModel.getColumn(i).setPreferredWidth(w[i]);
    }
}

From source file:SortableTable.java

/**
 * Changes the model for the table.  Takes care of updating the header listener at the
 * same time.//from   w  w w  . ja v  a2s.c  om
 *
 * @param model  the table model.
 *
 */
public void setSortableModel(final SortableTableModel model) {

    super.setModel(model);
    this.headerListener.setTableModel(model);
    final SortButtonRenderer renderer = new SortButtonRenderer();
    final TableColumnModel cm = getColumnModel();
    for (int i = 0; i < cm.getColumnCount(); i++) {
        cm.getColumn(i).setHeaderRenderer(renderer);
    }
    model.sortByColumn(0, true);

}

From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java

/**
 * Returns the leading X coordinate (within the table of data) of the given
 * column. This is a helper method for the table header cell renderers.
 *//*from w ww.  j  a  v a2 s  .c o m*/
int getXPositionOfColumn(final TableColumnModel model, final int columnIndex) {
    int sum = 0;
    for (int i = 0; i < columnIndex; i++) {
        sum += model.getColumn(i).getWidth();
    }
    logger.debug("X position of column " + columnIndex + " is " + sum + " according to " + model);
    return sum;
}

From source file:SortableTable.java

/**
 * Standard constructor - builds a table for the specified model.
 *
 * @param model  the data.//from  w  w  w.  ja va 2  s  . c  o  m
 */
public SortableTable(final SortableTableModel model) {

    super(model);

    final SortButtonRenderer renderer = new SortButtonRenderer();
    final TableColumnModel cm = getColumnModel();
    for (int i = 0; i < cm.getColumnCount(); i++) {
        cm.getColumn(i).setHeaderRenderer(renderer);
    }

    final JTableHeader header = getTableHeader();
    this.headerListener = new SortableTableHeaderListener(model, renderer);
    header.addMouseListener(this.headerListener);
    header.addMouseMotionListener(this.headerListener);

    model.sortByColumn(0, true);

}

From source file:net.sf.jabref.gui.preftabs.TableColumnsTab.java

/**
 * Customization of external program paths.
 *
 * @param prefs a <code>JabRefPreferences</code> value
 */// w w  w.  j a v a  2  s.c om
public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) {
    this.prefs = prefs;
    this.frame = frame;
    setLayout(new BorderLayout());

    TableModel tm = new AbstractTableModel() {

        @Override
        public int getRowCount() {
            return rowCount;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            int internalRow = row;
            if (internalRow == 0) {
                return column == 0 ? InternalBibtexFields.NUMBER_COL : String.valueOf(ncWidth);
            }
            internalRow--;
            if (internalRow >= tableRows.size()) {
                return "";
            }
            Object rowContent = tableRows.get(internalRow);
            if (rowContent == null) {
                return "";
            }
            TableRow tr = (TableRow) rowContent;
            // Only two columns
            if (column == 0) {
                return tr.getName();
            } else {
                return tr.getLength() > 0 ? Integer.toString(tr.getLength()) : "";
            }
        }

        @Override
        public String getColumnName(int col) {
            return col == 0 ? Localization.lang("Field name") : Localization.lang("Column width");
        }

        @Override
        public Class<?> getColumnClass(int column) {
            if (column == 0) {
                return String.class;
            }
            return Integer.class;
        }

        @Override
        public boolean isCellEditable(int row, int col) {
            return !((row == 0) && (col == 0));
        }

        @Override
        public void setValueAt(Object value, int row, int col) {
            tableChanged = true;
            // Make sure the vector is long enough.
            while (row >= tableRows.size()) {
                tableRows.add(new TableRow("", -1));
            }

            if ((row == 0) && (col == 1)) {
                ncWidth = Integer.parseInt(value.toString());
                return;
            }

            TableRow rowContent = tableRows.get(row - 1);

            if (col == 0) {
                rowContent.setName(value.toString());
                if ("".equals(getValueAt(row, 1))) {
                    setValueAt(String.valueOf(BibtexSingleField.DEFAULT_FIELD_LENGTH), row, 1);
                }
            } else {
                if (value == null) {
                    rowContent.setLength(-1);
                } else {
                    rowContent.setLength(Integer.parseInt(value.toString()));
                }
            }
        }

    };

    colSetup = new JTable(tm);
    TableColumnModel cm = colSetup.getColumnModel();
    cm.getColumn(0).setPreferredWidth(140);
    cm.getColumn(1).setPreferredWidth(80);

    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:pref", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JPanel pan = new JPanel();
    JPanel tabPanel = new JPanel();
    tabPanel.setLayout(new BorderLayout());
    JScrollPane sp = new JScrollPane(colSetup, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200));
    sp.setMinimumSize(new Dimension(250, 300));
    tabPanel.add(sp, BorderLayout.CENTER);
    JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
    toolBar.setFloatable(false);
    AddRowAction addRow = new AddRowAction();
    DeleteRowAction deleteRow = new DeleteRowAction();
    MoveRowUpAction moveUp = new MoveRowUpAction();
    MoveRowDownAction moveDown = new MoveRowDownAction();
    toolBar.setBorder(null);
    toolBar.add(addRow);
    toolBar.add(deleteRow);
    toolBar.addSeparator();
    toolBar.add(moveUp);
    toolBar.add(moveDown);
    tabPanel.add(toolBar, BorderLayout.EAST);

    fileColumn = new JCheckBox(Localization.lang("Show file column"));
    urlColumn = new JCheckBox(Localization.lang("Show URL/DOI column"));
    preferUrl = new JRadioButton(Localization.lang("Show URL first"));
    preferDoi = new JRadioButton(Localization.lang("Show DOI first"));
    ButtonGroup preferUrlDoiGroup = new ButtonGroup();
    preferUrlDoiGroup.add(preferUrl);
    preferUrlDoiGroup.add(preferDoi);

    urlColumn.addChangeListener(arg0 -> {
        preferUrl.setEnabled(urlColumn.isSelected());
        preferDoi.setEnabled(urlColumn.isSelected());
    });
    arxivColumn = new JCheckBox(Localization.lang("Show ArXiv column"));

    Collection<ExternalFileType> fileTypes = ExternalFileTypes.getInstance().getExternalFileTypeSelection();
    String[] fileTypeNames = new String[fileTypes.size()];
    int i = 0;
    for (ExternalFileType fileType : fileTypes) {
        fileTypeNames[i++] = fileType.getName();
    }
    listOfFileColumns = new JList<>(fileTypeNames);
    JScrollPane listOfFileColumnsScrollPane = new JScrollPane(listOfFileColumns);
    listOfFileColumns.setVisibleRowCount(3);
    extraFileColumns = new JCheckBox(Localization.lang("Show extra columns"));
    extraFileColumns.addChangeListener(arg0 -> listOfFileColumns.setEnabled(extraFileColumns.isSelected()));

    /*** begin: special table columns and special fields ***/

    JButton helpButton = new HelpAction(Localization.lang("Help on special fields"), HelpFile.SPECIAL_FIELDS)
            .getHelpButton();

    rankingColumn = new JCheckBox(Localization.lang("Show rank"));
    qualityColumn = new JCheckBox(Localization.lang("Show quality"));
    priorityColumn = new JCheckBox(Localization.lang("Show priority"));
    relevanceColumn = new JCheckBox(Localization.lang("Show relevance"));
    printedColumn = new JCheckBox(Localization.lang("Show printed status"));
    readStatusColumn = new JCheckBox(Localization.lang("Show read status"));

    // "sync keywords" and "write special" fields may be configured mutually exclusive only
    // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter does not make sense)
    // To avoid confusion, we opted to make the setting mutually exclusive
    syncKeywords = new JRadioButton(Localization.lang("Synchronize with keywords"));
    writeSpecialFields = new JRadioButton(
            Localization.lang("Write values of special fields as separate fields to BibTeX"));
    ButtonGroup group = new ButtonGroup();
    group.add(syncKeywords);
    group.add(writeSpecialFields);

    specialFieldsEnabled = new JCheckBox(Localization.lang("Enable special fields"));
    specialFieldsEnabled.addChangeListener(event -> {
        boolean isEnabled = specialFieldsEnabled.isSelected();
        rankingColumn.setEnabled(isEnabled);
        qualityColumn.setEnabled(isEnabled);
        priorityColumn.setEnabled(isEnabled);
        relevanceColumn.setEnabled(isEnabled);
        printedColumn.setEnabled(isEnabled);
        readStatusColumn.setEnabled(isEnabled);
        syncKeywords.setEnabled(isEnabled);
        writeSpecialFields.setEnabled(isEnabled);
    });

    builder.appendSeparator(Localization.lang("Special table columns"));
    builder.nextLine();
    builder.append(pan);

    DefaultFormBuilder specialTableColumnsBuilder = new DefaultFormBuilder(
            new FormLayout("8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow",
                    "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref"));
    CellConstraints cc = new CellConstraints();

    specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3));
    specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2));
    specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 3, 2));
    specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 4, 2));
    specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 5, 2));
    specialTableColumnsBuilder.add(printedColumn, cc.xyw(2, 6, 2));
    specialTableColumnsBuilder.add(readStatusColumn, cc.xyw(2, 7, 2));
    specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 10, 2));
    specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 11, 2));
    specialTableColumnsBuilder.add(helpButton, cc.xyw(1, 12, 2));

    specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2));
    specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 2, 2));
    specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 3));
    specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 4));
    specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 5, 2));

    specialTableColumnsBuilder.add(extraFileColumns, cc.xyw(5, 6, 2));
    specialTableColumnsBuilder.add(listOfFileColumnsScrollPane, cc.xywh(5, 7, 2, 6));

    builder.append(specialTableColumnsBuilder.getPanel());
    builder.nextLine();

    /*** end: special table columns and special fields ***/

    builder.appendSeparator(Localization.lang("Entry table columns"));
    builder.nextLine();
    builder.append(pan);
    builder.append(tabPanel);
    builder.nextLine();
    builder.append(pan);
    JButton buttonWidth = new JButton(new UpdateWidthsAction());
    JButton buttonOrder = new JButton(new UpdateOrderAction());
    builder.append(buttonWidth);
    builder.nextLine();
    builder.append(pan);
    builder.append(buttonOrder);
    builder.nextLine();
    builder.append(pan);
    builder.nextLine();
    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
}