English 中文(简体)
价值 名单选修 不工作的名单
原标题:valueChanged in ListSelectionListener not working

我设立了以下班级,以实施名单-选举-生计接口。 这一类别应该“列入”我所创立的一位独立党的甄选活动。 每当使用点击这一清单的行文时,就应当更新选定的“增长值”,因此,“选择的格式行号是......”。 然而,在一次以上点击之后,选定的“增长值”并没有变化。 没有人能够向我解释这一点,并且希望,这是我想要做的事。 预告!

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]);
            }

        }
  }


 }   
最佳回答

我读到的就是说,<代码>ListSelection 活动仅告诉你,<代码>Index和lastIndex之间的选择发生了变化,但没有朝此方向改变。 一旦知道发生了变化(<代码>ListSelection)。 内容提要 JList :

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

如果用户操作根本不选择唯一的选择,请核对<代码>选择_row是不否定的。

问题回答

Can you please share the code that attaches this listener the the JList? It should be something like:

list = new JList(listData);
listSelectionModel = list.getSelectionModel();
listSelectionModel.addListSelectionListener(
         new FormatListSelectionListener());

。 如何撰写候选人名单

你们想要检查的是,是否真的? 因为这意味着事件发生了变化。 这可能是为什么它一劳永逸地工作(第一次可能不会改变)以及工作之后。

而且,我也这样说,如果(例如)植被恢复肥料价值,它就会说。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签