java文件位置背景选择器不工作

时间:2015-12-23 23:57:12

标签: java

我正在尝试为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);
            }
        });

0 个答案:

没有答案