Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7989173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:40:38+00:00 2026-06-04T12:40:38+00:00

Hi there mighty programmers, once again as n00b beginner I am asking for your

  • 0

Hi there mighty programmers, once again as n00b beginner I am asking for your help…

Problem is as follows, I have a child window, containing some labels, buttons and two drop down menus. I want to have a SelectionListener on one combo box, named ‘name’ so that selected value from this drop down will affect the selected value in the second Combo – desc.

How to do that?

if I uncomment

//desc.select(name.getSelectionIndex());

in

name.addSelectionListener(new SelectionAdapter())

eclipse wants me to change Combo desc and Combo name to final, which is not possible cuz it will require initialising them outside the loop spoiling my layout 🙁

Here is the code:

public void tariffAddWindow(final Shell childWindow) {

    childWindow.setText("add dialog");

    labels = new Label[operatorTariffData.getColumnNames().length];
    inputTexts = new Text[operatorTariffData.getColumnNames().length];
    final Button buttons[] = new Button[operatorTariffData.getColumnNames().length];

    Combo name = null;
    Combo desc = null;

    for (int i =1; i< operatorTariffData.getColumnNames().length; i++) {


            labels[i] = new Label(childWindow, SWT.NONE);
            labels[i].setText(operatorTariffData.getColumnNames()[i].toString());
            labels[i].setBackground(blue);          

        if (i == 3) {
            name = new Combo(childWindow, SWT.READ_ONLY | SWT.BORDER);
            name.setLayoutData(tLayout);
            buttons[i] = new Button(childWindow, SWT.PUSH);
            buttons[i].setText("e");
        } else if (i == 4) {
            desc = new Combo(childWindow, SWT.READ_ONLY | SWT.BORDER);
            desc.setLayoutData(tLayout);
            buttons[i] = new Button(childWindow, SWT.PUSH);
            buttons[i].setText("e");
        } else {

            inputTexts[i] = new Text(childWindow, SWT.None);
            //texts[i].setText(data.getData()[i].toString());
            inputTexts[i].setLayoutData(tLayout);

            buttons[i] = new Button(childWindow, SWT.TOGGLE);
            buttons[i].setText("x");
            buttons[i].setSelection(false);
        }
    }

    for (int i = 1; i < contentProvider.getTariffNames().getQueryRowCount(); i++) {
        name.add(contentProvider.getTariffNames().getQueryData()[i][3].toString());
        desc.add(contentProvider.getTariffNames().getQueryData()[i][2].toString());
    }

    name.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            //desc.select(name.getSelectionIndex());
        }
    });
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:40:40+00:00Added an answer on June 4, 2026 at 12:40 pm
    1. You can make desc and name fields in the class instead:

      class Foo extends Composite
      {
          Combo name;
          Combo desc;
      
          public void tarriffAddWindow(final Shell childWindow)
          {
              // ...
              name.addSelectionListener(new SelectionAdapter() {
                  public void widgetSelected(SelectionEvent e)
                      desc.select(name.getSelectionIndex());
                  }
              });
          }
      }
      
    2. You can simply set a final variable to desc and name:

      final Combo descRef = desc;
      final Combo nameRef = name;
      
      nameRef.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e)
              descRef.select(nameRef.getSelectionIndex());
          }
      });
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There might be similar questions but I still have some parts that I couldn't
There might be an easy solution here, but it seems to have me tripped
I recently installed Visual Studio 2010 Pro. There might have been a link to
my robotics lab is looking for programmers to work on some projects we have
A number of programmers I work with have ISAPI_Rewrite 3 set-up on their local
I have a challenge I need some input on. I am currently recruiting programmers
Background: we are a small webdevelopment company. We have 5 programmers that produce 70%
I have a problem where I have a series of points for a simple,
Would any experienced Erlang programmers out there ever recommend association lists over records? One
In the same way we have coding standards, can there be things such as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.