Closed. This question needs details or clarity。它当前不接受答案。
                            
                        
                    
                
            
                    
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
                        
                        3年前关闭。
                    
                
        

当我从Jlist中选择一个值时,我想将其附加到Jtextfield而不替换现有值,
到目前为止,这是我尝试过的,您可以看到这正在替换现有值

    jlist.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent arg0) {
            if (!arg0.getValueIsAdjusting()) {
                textField.setText(jlist.getSelectedValue());

            }
        }


请帮我解决这个问题

最佳答案

澄清:

jlist.addListSelectionListener(new ListSelectionListener() {

    @Override
    public void valueChanged(ListSelectionEvent arg0) {
        if (!arg0.getValueIsAdjusting()) {
            textField.setText(textField.getText() + jlist.getSelectedValue());

        }
    }

10-05 19:13