这是我的代码。为什么这些值没有进入第二个 JList?此外,第二个 Jlist 不可见。所有导入都已到位,并且在以下代码中不可见:
public class Gui extends JFrame {
private JList l;
private JList l2;
private JButton b1;
public String [] cd = {"Album a", "Album b", "Album c", "Album d","Album e", "Album f", "Album g", "Album h"};
public Gui(){
super("Mover");
l = new JList (cd);
l.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
b1 = new JButton("Move");
b1.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event){
l2.setListData(l.getSelectedValuesList());
}
}
);
setLayout(new FlowLayout());
add(new JScrollPane(l));
add(b1);
add(new JScrollPane(l2));
}
}