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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:13:55+00:00 2026-05-17T01:13:55+00:00

I have created the following class implementing a ListSelectionListener interface. This class should listen

  • 0

I have created the following class implementing a ListSelectionListener interface. This class should “listen” to the selection events of a JList I have created. Everytime the use clicks on a row of this list, the selected_row value should be updated and the string “The format row selected is ….” should therefore change. However after clicking the rows more than once, the select_row value doesn’t change. Can anybody provide me a with an explanation for this and hopefully, a way to do what I want? Thanks in advance!!

import java.util.List;

import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import ee.dobax.portal.CommonPath;

public class FormatListSelectionListener implements ListSelectionListener{

public ContentGenerated content;
private CommonPathList path_list;
private ConfigRenderingDialog dialog;

public FormatListSelectionListener(ConfigRenderingDialog dialog){

    content = dialog.content;
    path_list = dialog.pathList;
}

public void valueChanged(ListSelectionEvent e) {
    int selected_row;

    if(e.getValueIsAdjusting() == false){
        selected_row = e.getLastIndex();


    System.out.println("The format row selected is "+selected_row);
        path_list.addFormatListRowSelected(selected_row);

        List<CommonPath> list_p = content.getPathList(selected_row);

        Object[] path_list_to_array = new Object[list_p.size()];

        path_list.getContents().removeAllElements();

        for(int x = 0; x < list_p.size(); x++){
            path_list_to_array[x] = list_p.get(x);
            path_list.getContents().addElement(path_list_to_array[x]);
            }

        }
  }


 }   
  • 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-17T01:13:56+00:00Added an answer on May 17, 2026 at 1:13 am

    I read the docs as indicating that the ListSelectionEvent only tells you that the selection between firstIndex and lastIndex was changed, but not in which direction. Once you know that a change has occurred (that a ListSelectionEvent has been fired) you could just read the current selected value from the JList:

    selected_row = ((JList) e.getSource()).getSelectedIndex();
    

    You’ll want to check selected_row is non-negative, in case the user operation is simply unselecting the only selected option.

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

Sidebar

Related Questions

I have created the following class class Contact def initialize(id, name, phone) @id =
In Java I have created the following class which extends ImageView to create a
I have an ExpenseType object that I have created with the following migration: class
I have created mock: GuiExHandler mockGuiEx = EasyMock.createMock(MockedClass.class); And Im getting following exception: Testcase:
I am following the guide at http://guides.rubyonrails.org/association_basics.html and I have created class Customer <
I have an the following class I'm trying to create a list of with
I have the following code that creates a serverside object of the xmlhttp class.
I have the following templated function... template< class T > T *create_object( lua_State *L
I have created following rule in the .htaccess file located at the root of
I have created following thing in android using android compatibility support package Basically i

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.