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 6042441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:47:27+00:00 2026-05-23T06:47:27+00:00

I’m having a poblem with my project, basically its a small app that stores

  • 0

I’m having a poblem with my project, basically its a small app that stores synonyms.
I have 2 JPanels populated with two JLists, one for the list of words and one with the correspondent synonyms.
When you click on a word on one JList, the correspondent synonyms appears on the other JList
then there are 2 JTextFields, for adding a word-synonym pair, in one field you insert the word in the other you insert the synonyms, split them creating an array with synonyms.split(” “) and store all in a Map
this is the ListSelectionListener i have added to the word JList

    woordenList.addListSelectionListener(new ListSelectionListener() {

              public void valueChanged(ListSelectionEvent evt) {

                if (evt.getValueIsAdjusting()){

                  return;
                }

                getSynoniemen(evt);
             }
            });

And this is the method that gets the synonyms

    private void getSynoniemen(ListSelectionEvent e){

    if(e.getValueIsAdjusting()){


        return;

     }else{


         String woord=(String)woordenList.getSelectedValue();

         Object[] synArray=(Object[])beheer.getValues(woord);

         synoniemenList.setListData(synArray);

     }

}

If i add a word and synonyms into the lists when no item is selected it works fine, if i do this operation of adding items while instead, i have a word selected in the word-JList, the method getValues() with a null string is called, throwing an exception. i dont understand why, adding an element on the list also fires a list selection.
Any advice?

  • 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-05-23T06:47:27+00:00Added an answer on May 23, 2026 at 6:47 am

    i dont understand why, adding an element on the list also fires a list selection.

    Somewhere in your code you must be changing the selected index.

    Download and test the ListDemo example for How to Use Lists. When you run the code and “Hire” a person, then the list selection event fires (I added a System.out.println(…) to the listener). Then if you comment out:

    //            list.setSelectedIndex(index);
    

    the event is not fired. So you have a problem in your code. Compare your code to the working example code to see what if different.

    If you need more help then post a SSCCE that demonstrates the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an array which has BIG numbers and small numbers in it. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small

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.