Bonjour à tous,

Je suis en train de développer une petite application en java, et j'ai une erreur avec un JFileChooser...
Je ne comprend vraiment pas pourquoi le code bug, le peu qu'il y a ne me parait pas incorrect.

Voilà le code de ma classe
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
 
 
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
 
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
 
public class Fenetre extends JFrame {
 
	private JPanel jContentPane;
	private JLabel jLabelFichier;
	private JTextField jTextFieldAdresseDBF;
	private JButton jButton;
 
		public Fenetre(){
			//Théme de la fenetre (ici Windows XP)
			String lnfName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
			try {
				UIManager.setLookAndFeel(lnfName);
				SwingUtilities.updateComponentTreeUI(this);
			} 
			catch (ClassNotFoundException e) {e.printStackTrace();} 
			catch (InstantiationException e) {e.printStackTrace();} 
			catch (IllegalAccessException e) {e.printStackTrace();}
			catch (UnsupportedLookAndFeelException e) {e.printStackTrace();}
 
			//Attributs de la fenêtre
			this.setSize(300, 150);
			this.setTitle("Mise aux normes fichier DBF");
			this.setResizable(true);
			this.setLocationRelativeTo(null); //Postionnement au centre
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Fermeture lorsque l'on clique sur la croix
			this.setContentPane(getJContentPane()); //déclaration du contentPane
 
			//Attribut du content pane
			jContentPane.setBackground(Color.decode("#A3CCED")); //Modification de l'écran de fond
 
 
			//Configuration du Jpanel
			jContentPane.setBorder(BorderFactory.createTitledBorder("Sélection du fichier"));
			jContentPane.setLayout(new GridBagLayout());
			jContentPane.setBackground(Color.decode("#A3CCED"));
			jContentPane.setVisible(true);
 
			//Configuration du layout
			GridBagConstraints gbcMajZip = new GridBagConstraints();
			gbcMajZip.anchor = GridBagConstraints.BASELINE_LEADING;
 
			//Configuration des composants
			jLabelFichier = new JLabel("Fichier");
			jTextFieldAdresseDBF = new JTextField(15);
			jButton = new JButton("Sélection");
 
			//Ajout des composants 
			jContentPane.add(jLabelFichier);
			jContentPane.add(jTextFieldAdresseDBF);
			jContentPane.add(jButton);
 
			this.setVisible(true);
 
			//Listener
			jButton.addActionListener(new jButtonListener());
 
		}
 
		 private JPanel getJContentPane() {
			    if (jContentPane == null) {
			         jContentPane = new JPanel();
			    }
			    return jContentPane;
		}
 
		 /**
                 * classe qui écoute notre bouton du fichier dbf
                 */
		 class jButtonListener implements ActionListener{
			 public void actionPerformed(ActionEvent arg0){
				 JFileChooser jFileChooser = new JFileChooser(); 
				 jFileChooser.setApproveButtonText("OK");
		 		 jFileChooser.setVisible(true);
		 		 jFileChooser.setSelectedFile(new File(""));
		 		if (jFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION){	
		 			//adresseMAJZip = (jFileChooserMAJZip.getSelectedFile().getAbsolutePath()); 
		 			jTextFieldAdresseDBF.setText((jFileChooser.getSelectedFile().getAbsolutePath()));
		 		}
		 	}
		 } 
 
 
 
 
}
Et voici l'erreur retournée lors de l'éxecution de ma classe main (qui instancie un nouvel objet Fenetre).

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at javax.swing.ImageIcon.<init>(ImageIcon.java:161)
	at javax.swing.ImageIcon.<init>(ImageIcon.java:147)
	at sun.swing.WindowsPlacesBar.<init>(WindowsPlacesBar.java:82)
	at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(WindowsFileChooserUI.java:508)
	at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(WindowsFileChooserUI.java:190)
	at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:136)
	at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(WindowsFileChooserUI.java:127)
	at javax.swing.JComponent.setUI(JComponent.java:668)
	at javax.swing.JFileChooser.updateUI(JFileChooser.java:1762)
	at javax.swing.JFileChooser.setup(JFileChooser.java:360)
	at javax.swing.JFileChooser.<init>(JFileChooser.java:333)
	at javax.swing.JFileChooser.<init>(JFileChooser.java:286)
	at Fenetre$jButtonListener.actionPerformed(Fenetre.java:90)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6038)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
	at java.awt.Component.processEvent(Component.java:5803)
	at java.awt.Container.processEvent(Container.java:2058)
	at java.awt.Component.dispatchEventImpl(Component.java:4410)
	at java.awt.Container.dispatchEventImpl(Container.java:2116)
	at java.awt.Component.dispatchEvent(Component.java:4240)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
	at java.awt.Container.dispatchEventImpl(Container.java:2102)
	at java.awt.Window.dispatchEventImpl(Window.java:2429)
	at java.awt.Component.dispatchEvent(Component.java:4240)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Une idée du probléme?