Example usage for javax.swing JComboBox setToolTipText

List of usage examples for javax.swing JComboBox setToolTipText

Introduction

In this page you can find the example usage for javax.swing JComboBox setToolTipText.

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:net.brtly.monkeyboard.plugin.ConsolePanel.java

public ConsolePanel(PluginDelegate service) {
    super(service);
    setLayout(new MigLayout("inset 5", "[grow][:100:100][24:n:24][24:n:24]", "[::24][grow]"));

    JComboBox comboBox = new JComboBox();
    comboBox.setToolTipText("Log Level");
    comboBox.setMaximumRowCount(6);//from   ww  w. j  av  a 2  s  .  c o m
    comboBox.setModel(
            new DefaultComboBoxModel(new String[] { "Fatal", "Error", "Warn", "Info", "Debug", "Trace" }));
    comboBox.setSelectedIndex(5);
    add(comboBox, "cell 1 0,growx");

    JButton btnC = new JButton("");
    btnC.setToolTipText("Clear Buffer");
    btnC.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/clear-document.png")));
    btnC.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            logPangrams();
        }
    });
    add(btnC, "cell 2 0,wmax 24,hmax 26");

    tglbtnV = new JToggleButton("");
    tglbtnV.setToolTipText("Auto Scroll");
    tglbtnV.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/auto-scroll.png")));
    tglbtnV.setSelected(true);
    tglbtnV.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            if (ev.getStateChange() == ItemEvent.SELECTED) {
                _table.setAutoScroll(true);
            } else if (ev.getStateChange() == ItemEvent.DESELECTED) {
                _table.setAutoScroll(false);
            }
        }
    });

    add(tglbtnV, "cell 3 0,wmax 24,hmax 26");

    scrollPane = new JScrollPane();
    scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
        public void adjustmentValueChanged(AdjustmentEvent e) {
            // TODO figure out what to do with this event?
        }
    });

    add(scrollPane, "cell 0 1 4 1,grow");

    _table = new JLogTable("Time", "Source", "Message");

    _table.getColumnModel().getColumn(0).setMinWidth(50);
    _table.getColumnModel().getColumn(0).setPreferredWidth(50);
    _table.getColumnModel().getColumn(0).setMaxWidth(100);

    _table.getColumnModel().getColumn(1).setMinWidth(50);
    _table.getColumnModel().getColumn(1).setPreferredWidth(50);
    _table.getColumnModel().getColumn(1).setMaxWidth(100);

    _table.getColumnModel().getColumn(2).setMinWidth(50);
    _table.getColumnModel().getColumn(2).setWidth(255);

    _table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);

    scrollPane.setViewportView(_table);

    _appender = new JLogTableAppender();
    _appender.setThreshold(Level.ALL);
    Logger.getRootLogger().addAppender(_appender);
}

From source file:org.kineticsystem.commons.data.demo.panels.AggregationChartPane.java

/**
 * Constructor.//from   w  ww .ja va  2 s  .c o m
 * @param source This is the source list being modified ate the same time
 *     by many threads.
 */
public AggregationChartPane(ActiveList<RandomContact> source) {

    // Define aggregators.

    GroupAggregator[] aggregators = new GroupAggregator[] { new ContactsPerContinentAggr(),
            new AvgAgePerContinentAggr(), new MaxAgePerContinentAggr(), new MinAgePerContinentAggr() };

    // Aggregator selector.

    DefaultComboBoxModel groupComboModel = new DefaultComboBoxModel(aggregators);
    final JComboBox groupCombo = new JComboBox(groupComboModel);
    groupCombo.setSelectedIndex(1);
    groupCombo.setToolTipText("Select an aggregation function.");

    // Create the dataset.

    dataset = new DefaultCategoryDataset();
    List<Country> countries = RandomContactGenerator.getCountries();
    Set<String> continents = new TreeSet<String>();

    for (Country country : countries) {
        continents.add(country.getContinent());
    }

    for (String continent : continents) {
        dataset.setValue(0, continent, "");
    }

    // Define the aggregated list.

    groups = new GroupMapping<RandomContact>(source);
    groups.setAggregator(aggregators[0]);
    groups.getTarget().addActiveListListener(this);

    // Create the chart.

    JFreeChart chart = ChartFactory.createBarChart("", "Continent", groups.getAggregator().toString(), dataset,
            PlotOrientation.VERTICAL, true, // legend?
            true, // tooltips?
            false // URLs?
    );
    final ValueAxis axis = chart.getCategoryPlot().getRangeAxis();
    axis.setAutoRange(true);
    axis.setRange(0, 250);

    ChartPanel chartPanel = new ChartPanel(chart);

    // Create the selector.

    ActionListener groupComboListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            GroupAggregator aggr = (GroupAggregator) cb.getSelectedItem();
            groups.setAggregator(aggr);
            axis.setLabel(aggr.toString());
        }
    };
    groupCombo.addActionListener(groupComboListener);

    // Layout the GUI.

    Cell cell = new Cell();

    TetrisLayout groupTableLayout = new TetrisLayout(2, 1);
    groupTableLayout.setRowWeight(0, 0);
    groupTableLayout.setRowWeight(1, 100);

    setLayout(groupTableLayout);
    add(groupCombo, cell);
    add(chartPanel, cell);
}

From source file:com.eviware.soapui.impl.rest.panels.mock.RestMockResponseDesktopPanel.java

private JComboBox createStatusCodeCombo() {
    ComboBoxModel httpStatusCodeComboBoxModel = new HttpStatusCodeComboBoxModel();

    final JComboBox statusCodeCombo = new JComboBox(httpStatusCodeComboBoxModel);

    statusCodeCombo.setSelectedItem(CompleteHttpStatus.from(getModelItem().getResponseHttpStatus()));
    statusCodeCombo.setToolTipText("Set desired HTTP status code");
    statusCodeCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            getModelItem().setResponseHttpStatus(
                    ((CompleteHttpStatus) statusCodeCombo.getSelectedItem()).getStatusCode());
        }//from www.  j av a  2 s .  c  o m
    });
    return statusCodeCombo;
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

public JComboBox appendComboBox(String label, ComboBoxModel model, String tooltip) {
    JComboBox comboBox = new JComboBox(model);
    comboBox.setToolTipText(StringUtils.defaultIfEmpty(tooltip, null));
    comboBox.getAccessibleContext().setAccessibleDescription(tooltip);
    append(label, comboBox);//from  w  w w. j  a v a2 s. c  o m
    return comboBox;
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

public JComboBox appendComboBox(String label, Object[] values, String tooltip) {
    JComboBox comboBox = new JComboBox(values);
    comboBox.setToolTipText(StringUtils.defaultIfEmpty(tooltip, null));
    comboBox.getAccessibleContext().setAccessibleDescription(tooltip);
    append(label, comboBox);//ww  w . j  a  v a2  s  . c  o m
    return comboBox;
}

From source file:cool.pandora.modeller.ui.jpanel.base.SaveBagFrame.java

private JPanel createComponents() {
    final Border border = new EmptyBorder(5, 5, 5, 5);

    final TitlePane titlePane = new TitlePane();
    initStandardCommands();//from   ww  w .  j  a v  a2s  .  c  o  m
    final JPanel pageControl = new JPanel(new BorderLayout());
    final JPanel titlePaneContainer = new JPanel(new BorderLayout());
    titlePane.setTitle(bagView.getPropertyMessage("SaveBagFrame.title"));
    titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Define the Bag " + "settings")));
    titlePaneContainer.add(titlePane.getControl());
    titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
    pageControl.add(titlePaneContainer, BorderLayout.NORTH);
    final JPanel contentPane = new JPanel();

    // TODO: Add bag name field
    // TODO: Add save name file selection button
    final JLabel location = new JLabel("Save in:");
    final JButton browseButton = new JButton(getMessage("bag.button.browse"));
    browseButton.addActionListener(new SaveBagAsHandler());
    browseButton.setEnabled(true);
    browseButton.setToolTipText(getMessage("bag.button.browse.help"));
    final DefaultBag bag = bagView.getBag();
    if (bag != null) {
        bagNameField = new JTextField(bag.getName());
        bagNameField.setCaretPosition(bag.getName().length());
        bagNameField.setEditable(false);
        bagNameField.setEnabled(false);
    }

    // Holey bag control
    final JLabel holeyLabel = new JLabel(bagView.getPropertyMessage("bag.label.isholey"));
    holeyLabel.setToolTipText(bagView.getPropertyMessage("bag.isholey.help"));
    final JCheckBox holeyCheckbox = new JCheckBox(bagView.getPropertyMessage("bag.checkbox" + ".isholey"));
    holeyCheckbox.setBorder(border);
    holeyCheckbox.addActionListener(new HoleyBagHandler());
    holeyCheckbox.setToolTipText(bagView.getPropertyMessage("bag.isholey.help"));

    urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label"));
    urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description"));
    urlField = new JTextField("");
    try {
        assert bag != null;
        urlField.setText(bag.getFetch().getBaseURL());
    } catch (Exception e) {
        log.error("Failed to set url label", e);
    }
    urlField.setEnabled(false);

    // TODO: Add format label
    final JLabel serializeLabel;
    serializeLabel = new JLabel(getMessage("bag.label.ispackage"));
    serializeLabel.setToolTipText(getMessage("bag.serializetype.help"));

    // TODO: Add format selection panel
    noneButton = new JRadioButton(getMessage("bag.serializetype.none"));
    noneButton.setEnabled(true);
    final AbstractAction serializeListener = new SerializeBagHandler();
    noneButton.addActionListener(serializeListener);
    noneButton.setToolTipText(getMessage("bag.serializetype.none.help"));

    zipButton = new JRadioButton(getMessage("bag.serializetype.zip"));
    zipButton.setEnabled(true);
    zipButton.addActionListener(serializeListener);
    zipButton.setToolTipText(getMessage("bag.serializetype.zip.help"));

    /*
     * tarButton = new JRadioButton(getMessage("bag.serializetype.tar"));
     * tarButton.setEnabled(true);
     * tarButton.addActionListener(serializeListener);
     * tarButton.setToolTipText(getMessage("bag.serializetype.tar.help"));
     *
     * tarGzButton = new JRadioButton(getMessage("bag.serializetype.targz"));
     * tarGzButton.setEnabled(true);
     * tarGzButton.addActionListener(serializeListener);
     * tarGzButton.setToolTipText(getMessage("bag.serializetype.targz.help"));
     *
     * tarBz2Button = new JRadioButton(getMessage("bag.serializetype.tarbz2"));
     * tarBz2Button.setEnabled(true);
     * tarBz2Button.addActionListener(serializeListener);
     * tarBz2Button.setToolTipText(getMessage("bag.serializetype.tarbz2.help"));
     */

    short mode = 2;
    if (bag != null) {
        mode = bag.getSerialMode();
    }
    if (mode == DefaultBag.NO_MODE) {
        this.noneButton.setEnabled(true);
    } else if (mode == DefaultBag.ZIP_MODE) {
        this.zipButton.setEnabled(true);
    } else {
        this.noneButton.setEnabled(true);
    }

    final ButtonGroup serializeGroup = new ButtonGroup();
    serializeGroup.add(noneButton);
    serializeGroup.add(zipButton);
    // serializeGroup.add(tarButton);
    // serializeGroup.add(tarGzButton);
    // serializeGroup.add(tarBz2Button);
    final JPanel serializeGroupPanel = new JPanel(new FlowLayout());
    serializeGroupPanel.add(serializeLabel);
    serializeGroupPanel.add(noneButton);
    serializeGroupPanel.add(zipButton);
    // serializeGroupPanel.add(tarButton);
    // serializeGroupPanel.add(tarGzButton);
    // serializeGroupPanel.add(tarBz2Button);
    serializeGroupPanel.setBorder(border);
    serializeGroupPanel.setEnabled(true);
    serializeGroupPanel.setToolTipText(bagView.getPropertyMessage("bag.serializetype.help"));

    final JLabel tagLabel = new JLabel(getMessage("bag.label.istag"));
    tagLabel.setToolTipText(getMessage("bag.label.istag.help"));
    final JCheckBox isTagCheckbox = new JCheckBox();
    isTagCheckbox.setBorder(border);
    isTagCheckbox.addActionListener(new TagManifestHandler());
    isTagCheckbox.setToolTipText(getMessage("bag.checkbox.istag.help"));

    final JLabel tagAlgorithmLabel = new JLabel(getMessage("bag.label.tagalgorithm"));
    tagAlgorithmLabel.setToolTipText(getMessage("bag.label.tagalgorithm.help"));
    final ArrayList<String> listModel = new ArrayList<>();
    for (final Algorithm algorithm : Algorithm.values()) {
        listModel.add(algorithm.bagItAlgorithm);
    }
    final JComboBox<String> tagAlgorithmList = new JComboBox<>(listModel.toArray(new String[listModel.size()]));
    tagAlgorithmList.setName(getMessage("bag.tagalgorithmlist"));
    tagAlgorithmList.addActionListener(new TagAlgorithmListHandler());
    tagAlgorithmList.setToolTipText(getMessage("bag.tagalgorithmlist.help"));

    final JLabel payloadLabel = new JLabel(getMessage("bag.label.ispayload"));
    payloadLabel.setToolTipText(getMessage("bag.ispayload.help"));
    final JCheckBox isPayloadCheckbox = new JCheckBox();
    isPayloadCheckbox.setBorder(border);
    isPayloadCheckbox.addActionListener(new PayloadManifestHandler());
    isPayloadCheckbox.setToolTipText(getMessage("bag.ispayload.help"));

    final JLabel payAlgorithmLabel = new JLabel(bagView.getPropertyMessage("bag.label" + ".payalgorithm"));
    payAlgorithmLabel.setToolTipText(getMessage("bag.payalgorithm.help"));
    final JComboBox<String> payAlgorithmList = new JComboBox<String>(
            listModel.toArray(new String[listModel.size()]));
    payAlgorithmList.setName(getMessage("bag.payalgorithmlist"));
    payAlgorithmList.addActionListener(new PayAlgorithmListHandler());
    payAlgorithmList.setToolTipText(getMessage("bag.payalgorithmlist.help"));

    //only if bag is not null
    if (bag != null) {
        final String fileName = bag.getName();
        bagNameField = new JTextField(fileName);
        bagNameField.setCaretPosition(fileName.length());

        holeyCheckbox.setSelected(bag.isHoley());
        urlLabel.setEnabled(bag.isHoley());
        isTagCheckbox.setSelected(bag.isBuildTagManifest());
        tagAlgorithmList.setSelectedItem(bag.getTagManifestAlgorithm());
        isPayloadCheckbox.setSelected(bag.isBuildPayloadManifest());
        payAlgorithmList.setSelectedItem(bag.getPayloadManifestAlgorithm());
    }

    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints glbc = new GridBagConstraints();
    final JPanel panel = new JPanel(layout);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    int row = 0;

    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(location, glbc);
    panel.add(location);

    buildConstraints(glbc, 2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST);
    glbc.ipadx = 5;
    layout.setConstraints(browseButton, glbc);
    glbc.ipadx = 0;
    panel.add(browseButton);

    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    glbc.ipadx = 5;
    layout.setConstraints(bagNameField, glbc);
    glbc.ipadx = 0;
    panel.add(bagNameField);

    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(holeyLabel, glbc);
    panel.add(holeyLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.WEST, GridBagConstraints.WEST);
    layout.setConstraints(holeyCheckbox, glbc);
    panel.add(holeyCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(urlLabel, glbc);
    panel.add(urlLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(urlField, glbc);
    panel.add(urlField);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(serializeLabel, glbc);
    panel.add(serializeLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    layout.setConstraints(serializeGroupPanel, glbc);
    panel.add(serializeGroupPanel);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(tagLabel, glbc);
    panel.add(tagLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(isTagCheckbox, glbc);
    panel.add(isTagCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(tagAlgorithmLabel, glbc);
    panel.add(tagAlgorithmLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(tagAlgorithmList, glbc);
    panel.add(tagAlgorithmList);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(payloadLabel, glbc);
    panel.add(payloadLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(isPayloadCheckbox, glbc);
    panel.add(isPayloadCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(payAlgorithmLabel, glbc);
    panel.add(payAlgorithmLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(payAlgorithmList, glbc);
    panel.add(payAlgorithmList);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);

    GuiStandardUtils.attachDialogBorder(contentPane);
    pageControl.add(panel);
    final JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;

}

From source file:ffx.ui.ModelingPanel.java

private void initCommandComboBox(JComboBox commands) {
    commands.setActionCommand("FFXCommand");
    commands.setMaximumSize(xyzCommands.getPreferredSize());
    commands.setEditable(false);// w w  w  .j a  va2s  .co  m
    commands.setToolTipText("Select a Modeling Command");
    commands.setSelectedIndex(0);
    commands.addActionListener(this);
}

From source file:ome.formats.importer.gui.GuiCommonElements.java

/**
 * Add a combo box (with label) to parent container
 * //  w  w  w.ja  va2  s.co m
 * @param container - parent container
 * @param label - combo box label
 * @param initialValues - initial value for combo box
 * @param mnemonic - combo box mnemonic
 * @param tooltip - tool tip for combo box
 * @param labelWidth - width of label
 * @param placement - TableLayout placement in parent container
 * @param debug - turn on/off red debug borders
 * @return JComboBox
 */
public static JComboBox addComboBox(Container container, String label, Object[] initialValues, int mnemonic,
        String tooltip, double labelWidth, String placement, boolean debug) {
    JPanel panel = new JPanel();
    panel.setOpaque(false);

    double size[][] = { { labelWidth, TableLayout.FILL }, { TableLayout.PREFERRED } };
    TableLayout layout = new TableLayout(size);
    panel.setLayout(layout);

    JLabel labelTxt = new JLabel(label);
    labelTxt.setDisplayedMnemonic(mnemonic);
    panel.add(labelTxt, "0,0,L,C");

    JComboBox result = null;
    if (initialValues != null) {
        result = new JComboBox(initialValues);
    } else {
        result = new JComboBox();
    }
    labelTxt.setLabelFor(result);
    result.setToolTipText(tooltip);
    panel.add(result, "1,0,F,C");
    container.add(panel, placement);
    result.setOpaque(false);
    return result;
}

From source file:org.gcaldaemon.gui.config.MainConfig.java

public static final boolean selectItem(JComboBox combo, String value) {
    if (value == null || combo == null || value.length() == 0) {
        return false;
    }/*www  .j  ava  2 s.c  o  m*/
    ComboBoxModel model = combo.getModel();
    if (model != null) {
        int n, size = model.getSize();
        n = value.indexOf(" - ");
        if (n != -1) {
            value = value.substring(n + 3);
        }
        String test;
        for (int i = 0; i < size; i++) {
            test = (String) model.getElementAt(i);
            if (test != null) {
                n = test.indexOf(" - ");
                if (n != -1) {
                    test = test.substring(n + 3);
                }
                if (test.equals(value)) {
                    combo.setSelectedIndex(i);
                    combo.setToolTipText((String) model.getElementAt(i));
                    return true;
                }
            }
        }
    }
    if (combo.isEditable()) {
        combo.setSelectedItem(value);
        combo.setToolTipText(value);
        return true;
    }
    return false;
}

From source file:org.kineticsystem.commons.data.demo.panels.ContactFilterPane.java

/**
 * Default constructor.//from   w w  w  .ja  v a2s.co m
 * @param contacts The list of contacts to sort and filter.
 */
public ContactFilterPane(ActiveList<RandomContact> source) {

    //      source = new SortedList<RandomContact>(source);
    //      ((SortedList<RandomContact>) source).setComparator(new BeanComparator("name"));

    // Light table format.

    TableStructure lightTableFormat = new BeanTableStructure(new String[] { null, null, null, null },
            new String[] { "Name", "Surname", "Age", "Email" });

    TableCellRenderer[] lightTableRenderers = new TableCellRenderer[] {
            new ColorTableCellRenderer("name", null), new ColorTableCellRenderer("surname", null),
            new ColorTableCellRenderer("age", null), new ColorTableCellRenderer("email", null) };

    Comparator[] lightTableComparators = new Comparator[] { new BeanComparator("name"),
            new BeanComparator("surname"), new BeanComparator("age"), new BeanComparator("email") };

    String lightTableMessage = "Show name, surname, age and email";

    // Full table format.

    TableStructure fullTableFormat = new BeanTableStructure(new String[] { null, null, null, null, null, null },
            new String[] { "Name", "Surname", "Address", "Country", "Continent", "Email" });

    TableCellRenderer[] fullTableRenderers = new TableCellRenderer[] { new ColorTableCellRenderer("name", null),
            new ColorTableCellRenderer("surname", null), new ColorTableCellRenderer("address", null),
            new ColorTableCellRenderer("country", null), new ColorTableCellRenderer("continent", null),
            new ColorTableCellRenderer("email", null) };

    Comparator[] fullTableComparators = new Comparator[] { new BeanComparator("name"),
            new BeanComparator("surname"), new BeanComparator("address"), new BeanComparator("country"),
            new BeanComparator("continent"), new BeanComparator("email") };

    String fullTableMessage = "Show name, surname, address, country, " + "continent and email";

    // Table model and table view.

    tableModel = new TableModelAdapter(source, lightTableFormat);

    table = new JTable(tableModel);
    sorter = new TableRowSorter<TableModel>(tableModel);
    for (int i = 0; i < lightTableComparators.length; i++) {
        sorter.setComparator(i, lightTableComparators[i]);
        table.getColumnModel().getColumn(i).setCellRenderer(lightTableRenderers[i]);
    }
    table.setRowSorter(sorter);

    JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    // Table structure selector.

    DefaultComboBoxModel tableFormatComboModel = new DefaultComboBoxModel(new TableModeItem[] {
            new TableModeItem(lightTableMessage, lightTableFormat, lightTableRenderers, lightTableComparators),
            new TableModeItem(fullTableMessage, fullTableFormat, fullTableRenderers, fullTableComparators) });

    JComboBox formatCombo = new JComboBox(tableFormatComboModel);
    formatCombo.setToolTipText("Select a format.");
    formatCombo.addActionListener(new FormatComboActionListener());

    // Table filter selector.

    DefaultComboBoxModel filterComboModel = new DefaultComboBoxModel(
            new FilterComboItem[] { new FilterComboItem("Address", "address"),
                    new FilterComboItem("Country", "country"), new FilterComboItem("Email", "email"),
                    new FilterComboItem("Name", "name"), new FilterComboItem("Surname", "surname") });

    filterCombo = new JComboBox(filterComboModel);
    filterCombo.setToolTipText("Select a filter.");
    filterCombo.setSelectedIndex(3);

    filterText = new JTextField("");
    filterText.setToolTipText("Type a regular expression.");
    filterText.getDocument().addDocumentListener(new FilterDocumentListener());

    filterButton = new JButton("Filter");
    filterButton.setToolTipText("Press to filter.");
    filterButton.addActionListener(new FilterButtonActionListener());

    // Layout.

    Cell cell = new Cell();
    TetrisLayout filterLayout = new TetrisLayout(1, 3);
    filterLayout.setColWeight(0, 100);
    filterLayout.setColWeight(1, 0);
    filterLayout.setColWeight(2, 0);

    JPanel filterPane = new JPanel(filterLayout);
    filterPane.add(filterText, cell);
    filterPane.add(filterCombo, cell);
    filterPane.add(filterButton, cell);

    TetrisLayout tableLayout = new TetrisLayout(3, 1);
    tableLayout.setRowWeight(0, 0);
    tableLayout.setRowWeight(1, 0);
    tableLayout.setRowWeight(2, 100);

    setLayout(tableLayout);
    add(filterPane, cell);
    add(formatCombo, cell);
    add(tableScrollPane, cell);
}