我正在尝试为JFrame创建一个背景选择器,每次我尝试将背景设置为文件时它都不起作用
choose.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFileChooser openf = new JFileChooser();
Component j = null;
openf.showOpenDialog(j);
File fl = openf.getSelectedFile();
st = fl.getAbsolutePath();
String string = st.replace("\\", "\\\\");
path = string;
SwingUtilities.windowForComponent(p).dispose();
DFrame desktop = new DFrame();
DFrame.l.setIcon(new ImageIcon(getClass().getResource(path)));
desktop.setVisible(true);
}
});