J'ai une erreur à la compilation de mon code :

Exception in thread "main" java.lang.NullPointerException
at javaapplication7.Application.init(Application.java:21)
at javaapplication7.Application.<init>(Application.java:14)
at javaapplication7.Main.main(Main.java:26)
Java Result: 1

En me renseignant j'ai vu que cette erreur est dûe à une tentative d'accès à un objet non instancié, or dans mon cas je ne vois pas ce que je n'ai pas instancier.

mon code:

classe main :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
public class Main {
 
 
    public Main() {
    }
 
    public static void main(String[] args) {
        Application appli=new Application();
 
    }
 
}
la classe Application :
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
import java.io.File;
import javax.swing.JFileChooser;
 
 
public class Application {
    private Imag i;
    private InterfaceGraphique interGraph=null;
 
 
    public Application() {
 
        this.interGraph=new InterfaceGraphique(this);
        this.interGraph.setVisible(true);
        init();
 
    }
 
    public void init(){
 
        this.i=new Imag(interGraph.getG());
    }
 
    public void DemarrerAcquisition(){
        i.start();
    }
 
}
la classe InterfaceGraphique:
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
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.JPanel;
 
public class InterfaceGraphique extends javax.swing.JFrame {
    private Graphics g;
    private Application app=null;
 
 
 
 
    public InterfaceGraphique() {
 
    }
 
    public InterfaceGraphique(Application app) {
        initComponents();
        this.app=app;
        this.g=jPanelTrajet.getGraphics();
 
    }
 
    public void paint(Graphics g){
        super.paint(g);
    }
 
    public Graphics getG(){
        return this.g;
    }
 
 
    private void initComponents() {
//ici se trouve le code généré par netbeans que j ai effacé car trop long et inutile pour le forum
}                     
 
    private void jButtonOnActionPerformed(java.awt.event.ActionEvent evt) {                                          
repaint();
    }                                         
 
    public JPanel getPanelFichier(){
        return this.jPanelFichier;
    }
 
 
    public JPanel getPanelVisualisation(){
        return this.jPanelVisualisation;
    }
la classe Image:
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
 
import java.awt.*;
import java.io.File;
import javax.swing.*;
import java.awt.event.*;
 
public class Imag extends Thread {
 
    private Graphics g;
 
 
    public Imag() {
 
    }
 
    public Imag(Graphics g){
        this.g=g;
 
    }

l'erreur se situe dans la classe Application, quand j'appelle le constructeur de la clase Imag : this.i=new Imag(interGraph.getG());


Merci d'avance pour votre aide