Bonjour à tous,
J'ai essayé d'insérer une image dans le bouton 9, mais ça ne fonctionne pas...tous les boutons disparaissent et il ne reste que la fenêtre vide.
Quelqu'un peut m'aider ?
merci
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.image.BufferedImage;
import java.io.IOException;
 
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;
 
import com.sun.prism.Image;
 
 
public class Fenetre5 {
 
	JFrame frame;
	JPanel panel_1;
	JPanel panel_2;
	JPanel panel_3;
	JPanel panel_4;
	JPanel panel_5;
	JLabel labelHeader;
	JButton b2,b3,b4,b5,b6,b7,b8,b9;
 
	Fenetre5()
	{
		frame=new JFrame();
		frame.setSize(800,500);
		frame.setVisible(true);
		frame.setLocationRelativeTo(null);
 
		panel_1=new JPanel();
		panel_2=new JPanel();
		panel_3=new JPanel();
		panel_4=new JPanel();
		panel_5=new JPanel();
		labelHeader=new JLabel("      GRAPHICS UNIT INTERFACE-FRACTALS      ");
		labelHeader.setFont(new Font("Serif", Font.ROMAN_BASELINE, 16));
 
 
 
		Border lineBorder,lineBorder1;
		lineBorder = BorderFactory.createLineBorder(Color.gray,2);
	    lineBorder1=BorderFactory.createLineBorder(Color.green,1);
 
 
 
		b2=new JButton("Mandelbrot");
		b2.setBackground(Color.LIGHT_GRAY);
		b2.setForeground(Color.black);
		b2.setBorder(lineBorder);
 
		b3=new JButton("Julia");
		b3.setBackground(Color.LIGHT_GRAY);
		b3.setForeground(Color.black);
		b3.setBorder(lineBorder);
 
		b4=new JButton("Recursion");
		b4.setBackground(Color.LIGHT_GRAY);
		b4.setForeground(Color.black);
		b4.setBorder(lineBorder);
 
 
 
		b5=new JButton("Recursion");
		b5.setBackground(Color.LIGHT_GRAY);
		b5.setForeground(Color.black);
		b5.setBorder(lineBorder);
 
		b6=new JButton("Recursion");
		b6.setBackground(Color.LIGHT_GRAY);
		b6.setForeground(Color.black);
		b6.setBorder(lineBorder);
 
		b7=new JButton("Recursion");
		b7.setBackground(Color.LIGHT_GRAY);
		b7.setForeground(Color.black);
		b7.setBorder(lineBorder);
 
		b8=new JButton("");
		b8.setBackground(Color.LIGHT_GRAY);
		b8.setForeground(Color.black);
		b8.setBorder(lineBorder1);
 
		b9=new JButton("");
		b9.setBackground(Color.LIGHT_GRAY);
		b9.setForeground(Color.black);
		b9.setBorder(lineBorder1);
 
	/*
		try {
		BufferedImage	img = ImageIO.read(getClass().getResource("mandelbrot.jpg"));
			b9.setIcon(new ImageIcon(img));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	*/					
 
		panel_1.setBackground(new Color(229,255,204));
		panel_1.add(labelHeader);
		panel_2.setBackground(Color.white);
		panel_3.setBackground(Color.white);
		panel_4.setBackground(Color.white);
		panel_5.setBackground(Color.DARK_GRAY);
 
		frame.setLayout(new BorderLayout());
 
 
		frame.add(panel_1,BorderLayout.NORTH);
		frame.add(panel_2,BorderLayout.SOUTH);
		frame.add(panel_3,BorderLayout.EAST);
		frame.add(panel_4,BorderLayout.WEST);
		frame.add(panel_5,BorderLayout.CENTER);
 
 
		panel_5.setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
 
		///colonne 0
 
		gbc.insets=new Insets(6,6,6,6);
		gbc.ipadx=100;
		gbc.ipady=20;
 
		gbc.gridx=0;
		gbc.gridy=0;
		gbc.gridheight=3;
		gbc.fill=GridBagConstraints.VERTICAL;
		panel_5.add(b8,gbc);
 
		gbc.gridx=0;
		gbc.gridy=1;		
 
		gbc.gridx=0;
		gbc.gridy=2;		
 
		///colonne 1
 
		gbc.ipadx=100;
		gbc.insets=new Insets(6,6,6,6);
		gbc.gridheight=1;
 
		gbc.gridx=1;
		gbc.gridy=0;
		panel_5.add(b2,gbc);
 
 
		gbc.gridx=1;
		gbc.gridy=1;
		panel_5.add(b3,gbc);
 
 
		gbc.gridx=1;
		gbc.gridy=2;
		panel_5.add(b4,gbc);
 
		//colonne2
 
		gbc.gridx=2;
		gbc.gridy=0;
		panel_5.add(b5,gbc);
 
		gbc.gridx=2;
		gbc.gridy=1;
		panel_5.add(b6,gbc);
 
		gbc.gridx=2;
		gbc.gridy=2;
		panel_5.add(b7,gbc);
 
		// colonne 3
 
		gbc.gridx=3;
		gbc.gridy=0;
		gbc.gridheight=3;
		gbc.fill=GridBagConstraints.VERTICAL;
		panel_5.add(b9,gbc);
 
 
 
	}
 
 
	public static void main(String[] args) {
 
		new Fenetre5();
 
	}
 
}