Sandy_Hawkeye Sandy_Hawkeye
关注数: 0 粉丝数: 4 发帖数: 29 关注贴吧数: 6
各位大神帮我看一下这段代码,在添加文件的时候怎么不能显示出来 public class MidaPlayerKnoledge extends JFrame { Vector<String> playlist1; File file[]; public static MidaPlayerKnoledge musicplayer = null; private FileInput fileinput = null; private JList jListMusic; private Vector<String> playlist; JPanel jp; public void franch(){ jp=new JPanel(); jp.setSize(200, 300); jp.setLocation(100, 100); jp.setBackground(Color.blue); this.getContentPane().add(jp); JMenu menu=new JMenu("打开"); JMenuItem mi=new JMenuItem("文件"); mi.addActionListener(new ActionListener(){ MidaPlayerKnoledge mpk=new MidaPlayerKnoledge(); public void actionPerformed(ActionEvent e) { JFileChooser jf=new JFileChooser("A:"); jf.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); jf.setMultiSelectionEnabled(true); jf.showOpenDialog(mpk); if(jf.showOpenDialog(mpk)==jf.APPROVE_OPTION){ file=jf.getSelectedFiles(); } String get; String[] name; List alist=new ArrayList(); if(file!=null){ name=new String[file.length]; for(int i=0;i<file.length;i++){ name[i]=file[i].getName(); alist.add(name[i]); } Iterator it=alist.iterator(); while(it.hasNext()){ get=(String) it.next(); int i=0; while(i==0){ JButton jb=new JButton(get); System.out.println(jb.getText()); jp.add(jb); i++; } mpk.repaint(); } } } }); menu.add(mi); JPanel jp=new JPanel(); JMenuBar mb=new JMenuBar(); mb.setSize(100, 100); mb.add(menu); this.getContentPane().add(mb); this.getContentPane().add(jp); this.setSize(600, 500); this.setLocationRelativeTo(null); this.setVisible(true); } public static void main(String[] args) { new MidaPlayerKnoledge().franch(); } }
1 下一页