changement

This commit is contained in:
diane 2023-03-21 12:02:26 +01:00
parent 21a3ca609b
commit 0981016863
7 changed files with 30 additions and 15 deletions

BIN
images/map1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

Before

Width:  |  Height:  |  Size: 379 KiB

After

Width:  |  Height:  |  Size: 379 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -52,6 +52,7 @@ public class JPanelImage extends JPanel {
g.drawImage(image, 0, 0, this.getWidth(),this.getHeight(), null);
}
}
}
//import java.awt.*;

View File

@ -28,6 +28,10 @@ import java.awt.event.ActionListener;
import java.io.IOException;
import java.awt.event.ActionEvent;
import java.awt.FlowLayout;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;
import java.awt.Font;
import java.awt.Window.Type;
@ -37,6 +41,7 @@ public class MaJFrame extends JFrame {
private static final long serialVersionUID = 7252959164975426293L;
private JPanelDessin panel_1;
private JPanelImage panel_2;
private JLabel lblNewLabel;
/**
@ -62,7 +67,7 @@ public class MaJFrame extends JFrame {
public MaJFrame() throws IOException {
// création et variablecontentPane
setTitle("Zombicide");
setIconImage(Toolkit.getDefaultToolkit().getImage(MaJFrame.class.getResource("/image/zombie.png")));
// setIconImage(Toolkit.getDefaultToolkit().getImage(MaJFrame.class.getResource("/images/zombie.png")));
setBackground(new Color(128, 0, 0));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
@ -81,9 +86,11 @@ public class MaJFrame extends JFrame {
panel.setLayout(new BorderLayout(0, 0));
JButton btnNewButton = new JButton("JOUER !");
btnNewButton.setForeground(new Color(255, 255, 255));
btnNewButton.setBackground(new Color(128, 128, 128));
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
clicBoutonJouer();
// clicBoutonJouer();
}
});
@ -100,16 +107,22 @@ public class MaJFrame extends JFrame {
//création panel_2 IMAGE
String mapPath = "map1.png";
// String mapPath = "image/map1.png";
//lecture de l'image
// Image img = ImageIO.read(getClass().getResource(mapPath));
panel_2 = new JPanelImage();
panel_2.setBackground(new Color(0, 0, 0));
panel_2 = new JPanelImage("map1.jpg");
// panel_2.setBackground(new Color(0, 0, 0));
panel_2.setBorder(null);
panel_2.setLayout(new BorderLayout(0, 0));
panel_2.add(panel_1, BorderLayout.CENTER);
// panel_2.add(panel_1, BorderLayout.CENTER);
contentPane.add(panel_2, BorderLayout.CENTER);
panel_2.setLayout(new BorderLayout(0, 0));
lblNewLabel = new JLabel("ZOMBICIDE");
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
lblNewLabel.setForeground(new Color(255, 255, 255));
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
panel_2.add(lblNewLabel, BorderLayout.CENTER);
panel_2.setVisible(true);
// panel_2.setImage(img);
// panel_2.setLayout(new GridLayout(1, 1, 0, 0));
@ -117,15 +130,16 @@ public class MaJFrame extends JFrame {
// String mapPath = "image/map1.png";
public void clicBoutonJouer() {
String mapPath = "map1.png";
if (panel_2 == null) {
// Handle error - panel_2 is not initialized
System.out.println("Error: panel_2 is null");
return;
}
panel_2.setImage(mapPath);
// JOptionPane.showMessageDialog(null, panel_2);
// String mapPath = "map1.png"; //"/F01_Zombie/src/image/map1.png";
// if (panel_2 == null) {
// // Handle error - panel_2 is not initialized
// System.out.println("Error: panel_2 is null");
// return;
// }
// panel_2.setImage(mapPath);
//// panel_1.setImage('zombie.png')
}
}

BIN
src/images/map1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 KiB

BIN
src/images/zombie.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB