我在MediaLibrary.java中有一个方法如下
private void playListActionPerformed(java.awt.event.ActionEvent evt) {
mediaLibraryDTO dto=new mediaLibraryDTO();
dto.setSongList(currentSongField.getText());
new Dashboard().libraryList(dto);
}
同样,我有MediaLibraryDTO.java如下
public class mediaLibraryDTO {
private String songList;
public String getSongList() {
return songList;
}
public void setSongList(String songList) {
this.songList = songList;
}
}
同样,我在Dashboard.java中有一个方法如下
public void libraryList(mediaLibraryDTO dto) {
File file = new File(dto.getSongList());
JOptionPane.showMessageDialog(null, file);
JList list = new JList(model);
model.addElement(file.toString());
playList.setModel(model);
}