Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Comboboxes linked together(data selected in first combo should filter data in second combo)
Comboboxes linked together [message #1219916] Fri, 06 December 2013 17:44
boby pietri is currently offline boby pietriFriend
Messages: 27
Registered: October 2013
Junior Member

I am trying to use ComboBoxCellEditor so I can put it in a TableViewer.
The first column should display a combo with some values ("Item One", "Item Two",...) and the 2nd another combo which depend on the value selected in first column ("Item One A", "Item One B",...). The 1st combobox filter the value of teh seconde one to resume
The snippet below does that but not in a tableviewer.
I'd like too use JFace ComboBoxCellEditor and CellEditor but I don't know how to "link" the 2 comboboxes using this way.

Thanks for your help.

package combo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class ComboExample2 {
  Display d;

  Shell s;

  ComboExample2() {
    d = new Display();
    s = new Shell(d);
    s.setSize(250, 250);
    s.setText("A Combo Example");
    final Combo c1 = new Combo(s, SWT.READ_ONLY);
    c1.setBounds(50, 50, 150, 65);
    final Combo c2 = new Combo(s, SWT.READ_ONLY);
    c2.setBounds(50, 85, 150, 65);
    String items[] = { "Item One", "Item Two", "Item Three", "Item Four",
        "Item Five" };
    c1.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        if (c1.getText().equals("Item One")) {
          String newItems[] = { "Item One A", "Item One B",
              "Item One C" };
        } else if (c1.getText().equals("Item Two")) {
          String newItems[] = { "Item Two A", "Item Two B",
              "Item Two C" };
        } else {
          c2.add("Not Applicable");
          c2.setText("Not Applicable");

    while (!s.isDisposed()) {
      if (!d.readAndDispatch())

  public static void main(String[] argv) {
    new ComboExample2();

Previous Topic:How to prevent Treeviewer from responding to "* " shortcut
Next Topic:Comboboxcelleditor how to select a specific item
Goto Forum:

Current Time: Mon Sep 21 20:11:51 GMT 2020

Powered by FUDForum. Page generated in 0.01894 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top