Salut
Voilà je me lance dans Java et j'ai commencé une petite application avec Eclipse sous Linux (ubuntu 10.10) qui fonctionne. J'ai importé mon projet avec Eclipse (window7 64 bits) et là ça marche plus
Le soucis vient surtout du fait que les images ne sont plus affichées voilà ce que je fais:
Ma classe fenêtre
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 public class JPlateau extends JPanel { private BufferedImage Damier; // Constructeur public JPlateau() { super(); try { Damier = ImageIO.read(new File("Graph/Damier.png")); } catch (IOException e) { System.out.println("Erreur chargement damier"); } } @Override public void paintComponent(final Graphics g) { super.paintComponent(g); g.drawImage(Damier, 0, 0, 1088, 576, 0, 0, 1088, 576, null); } }
et ma classe principale
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 public class MainFen extends JFrame implements MouseListener{ private JPlateau Plateau; public MainFen() { super(); build(); // MAJ(); } private void build() { setTitle("Ritmomachie"); setSize(1240, 860); setMinimumSize(new Dimension(1240,860)); setLocationRelativeTo(null); setResizable(true); addMouseListener(this); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setContentPane(buildContentPane()); MenuBar MainMenu=new MenuBar(); setMenuBar(MainMenu); Menu Partie= new Menu("Partie"); MainMenu.add(Partie); MenuItem Nouvelle=new MenuItem("Nouvelle"); Partie.add(Nouvelle); MenuItem Charger=new MenuItem("Charger"); Partie.add(Charger); MenuItem Sauver=new MenuItem("Sauver"); Partie.add(Sauver); } private JPanel buildContentPane() { Plateau = new JPlateau(); return Plateau; } @Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } }
Si quelqu'un a une idée?
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 public class Rithmomachie { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub SwingUtilities.invokeLater(new Runnable(){ public void run(){ MainFen MaFen = new MainFen(); MaFen.setVisible(true); } }); } }
Partager