Bonjour,
JToolBar toolBar = new JToolBar(); JButton button = new JButton("Ouvrir"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { JFileChooser fileChooser = new JFileChooser(); if(fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { File fichierdelecture= fileChooser.getSelectedFile(); System.out.println(fichierdelecture.getName()); } } }); toolBar.add(button); this.getContentPane().add(toolBar);
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JFileChooser.html
Crdt,
|