J'ai une fenêtre principale contenant un menu et une image de fond.
Mon problème étant que ma barre de menu ne s'affiche pas car elle passe sous l'image.
Voici le code de ma 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
 
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.Connection;
import java.sql.SQLException;
 
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
 
public class FenetrePrincipale extends JFrame implements ActionListener
{
	/**
         * 
         */
	private static final long serialVersionUID = 1L;
	//variable pour la construction de la barre de menu
	JMenuBar menuBar;
	JMenu menuDemarrer;
	JMenuItem menuConsulterPersonne,menuInsererPersonne,menuRechercherPersonne,menuQuitter;
 
	Toolkit test;
	Dimension dim;
	JDesktopPane panelPrincipale;
	AffichageImage imageAffiche; 
	public FenetrePrincipale()
	{
 
		test= Toolkit.getDefaultToolkit();
		dim=new Dimension();
		dim=test.getScreenSize();
 
 
//		jpanel
		panelPrincipale =new JDesktopPane();
		panelPrincipale.setBounds(0,0,800,640);
		imageAffiche = new AffichageImage("imagePrincipale.jpg",panelPrincipale);
		this.add(imageAffiche);
 
		constructionFrame();
		this.addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				System.exit(0);
			}
		});
 
 
	}
	public void constructionFrame()
	{
 
 
		//	construction de la barre de menu
		menuBar=new JMenuBar();
		menuDemarrer=new JMenu("Demarrer");
 
 
		menuConsulterPersonne=new JMenuItem("Consulter les personnes");
		menuConsulterPersonne.addActionListener(this);
 
		menuInsererPersonne=new JMenuItem("Inserer une personne");
		menuInsererPersonne.addActionListener(this);
 
		menuRechercherPersonne=new JMenuItem("Rechercher une personne");
		menuRechercherPersonne.addActionListener(this);
 
		menuQuitter=new JMenuItem("Quitter");
		menuQuitter.addActionListener(this);
 
		menuDemarrer.add(menuConsulterPersonne);
		menuDemarrer.addSeparator();
		menuDemarrer.add(menuInsererPersonne);
		menuDemarrer.addSeparator();
		menuDemarrer.add(menuRechercherPersonne);
		menuDemarrer.addSeparator();
		menuDemarrer.add(menuQuitter);
 
 
		menuBar.add(menuDemarrer);
		menuBar.setBounds(10,10,400,400);
		menuBar.setVisible(true);
		this.setJMenuBar(menuBar);
		this.getContentPane().add(panelPrincipale);
 
		//attribut de la fenetre
		this.setSize(800,640);
		this.setVisible(true);
 
		this.setLocation((dim.width-this.getWidth())/2,(dim.height-this.getHeight())/2);
		this.setTitle("Gestion des larges objects binary");
	}
 
 
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource()==menuConsulterPersonne)
		{
			String requete=new String("Select * from personne order by id_personne asc");
			FenetrePersonnel fenetreInfo=new FenetrePersonnel(this.connec,requete);
		}
		if(e.getSource()==menuInsererPersonne)
		{
			FenetreInsertionPersonne fenetreInsert=new FenetreInsertionPersonne(this.connec);
		}
		if(e.getSource()==menuRechercherPersonne)
		{
			FenetreRecherche fenetreRecherche=new FenetreRecherche(this.connec);
		}
		if(e.getSource()==menuQuitter)
		{
			try {
				this.connec.close();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			System.exit(0);
		}
	}
}
Voici le code pour afficher l'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
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
 
import java.awt.Canvas;
 
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
 
import javax.swing.JDesktopPane;
 
 
public class AffichageImage extends Canvas
{
	/**
         * 
         */
	private static final long serialVersionUID = 1L;
	//Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	int largeurEcran ;//= screenSize.width;
	int hauteurEcran;// = screenSize.height;
	Image image,imageScaled;
	int larg,longr;
 
	public AffichageImage(String url,JDesktopPane panelPhoto) 
	{
 
		larg=panelPhoto.getWidth();
		longr=panelPhoto.getHeight();
		image = Toolkit.getDefaultToolkit().getImage(url);
 
 
		largeurEcran = image.getWidth(this);
		hauteurEcran = image.getHeight(this);
 
		imageScaled = image.getScaledInstance(panelPhoto.getWidth(),panelPhoto.getHeight() , image.SCALE_DEFAULT);
		this.prepareImage(imageScaled, this);
	}
 
	public void paint(Graphics g) 
    {
		g.drawImage(imageScaled, 0, 0, this);
    }
 
 
	public boolean imageUpdate(Image image, int info, int x, int y, int l, int h) 
    {
	//	int rapport=0;
	/*	if((l!=0) && (h!=0))
		{
			if(l>h)
			{
				rapport=l/this.larg;
			}
			else
			{
				rapport=h/this.longr;
			}
 
			l=l/rapport;
			h=h/rapport;
		}
		*/
 
 
		if ((info & (WIDTH | HEIGHT)) != 0) 
		{
 
			setSize(larg,longr);
		}
 
		if ((info & (ALLBITS)) != 0) 
		{
			repaint();
			return false;
		}
		else 
		{
			return true;
		}
    }
 
}
Merci de votre aide.