我在尝试复制和粘贴代码时遇到了麻烦,它说的是关于未格式化的内容?我不知道这是我的第一次,但这是麻烦的代码,我将链接一个 pastebin,这样你也可以看到
整个代码: http: //pastebin.com/p6RQiSLz
有问题的代码:
//City (JList with txtfield)
pane.add(lblCity);
lblCity.setForeground(Color.BLACK);
lblCity.setBounds(5,260,80,25);
pane.add(list);
list.setSelectedIndex(0);
list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
list.setBackground(Color.BLACK);
list.setForeground(Color.WHITE);
list.setBounds(90,260,150,100);
list.setEnabled(false);
pane.add(txtCity);
txtCity.setBounds(90,380,150,25);
//================================TROUBLED BLOCK OF CODE============================================
list.addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent er){
txtCity.setText(listCity[listCity.getSelectedIndex]);
}
});