-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInterGraph.java
More file actions
83 lines (68 loc) · 2.54 KB
/
InterGraph.java
File metadata and controls
83 lines (68 loc) · 2.54 KB
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
package MasterM;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.plaf.LabelUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
public class InterGraph extends JFrame implements ActionListener{
private JPanel pan = new JPanel();
private JButton bouton = new JButton("PLAY");
private JButton bouton2 = new JButton("RULES");
private JButton bouton3 = new JButton("HOME");
private JPanel container = new JPanel();
private JLabel label = new JLabel("MASTERMIND");
private int compteur = 0;
public InterGraph(){
this.setTitle("MasterMind");
this.setSize(300, 300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setContentPane(new ImagePanel(new ImageIcon("mastermind.png").getImage())); //marche pas
container.setBackground(Color.lightGray);
container.setLayout(new BorderLayout());
container.add(pan, BorderLayout.CENTER);
bouton.addActionListener(this);
bouton2.addActionListener(this);
bouton3.addActionListener(this);
//Image img = ImageIO.read(new File("mastermind.png"));
//label.drawImage(img, 0, 0, this);
JPanel south = new JPanel();
south.add(bouton);
south.add(bouton2);
south.add(bouton3);
container.add(south, BorderLayout.SOUTH);
Font police = new Font("Tahoma", Font.BOLD, 12);
label.setFont(police);
label.setForeground(Color.BLACK);
label.setHorizontalAlignment(JLabel.CENTER);
container.add(label, BorderLayout.NORTH);
this.setContentPane(container);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent arg0) {
if(arg0.getSource() == bouton)
label.setText("Vous avez cliqué sur PLAY");
if(arg0.getSource() == bouton2)
label.setText("vous avez cliqué sur RULES");
if(arg0.getSource() == bouton3)
label.setText("MASTERMIND");
}
//…
}
//public void paintComponent(Graphics g){
// Font font = new Font("Arial", Font.BOLD, 20);
// g.setFont(font);
//g.setColor(Color.BLACK);
//g.drawString("Welcome to Mastermind", 10, 20);
//try {
// Image img = ImageIO.read(new File("mastermind.png"));
//g.drawImage(img, 0, 0, this);
//Pour une image de fond
//g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
//} catch (IOException e) {
//e.printStackTrace();
//}