bonjour à tous
je veux afficher un son quand je clic sur un bouton voici le code que j'ai
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
 
 
 
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.swing.JFrame;
import javax.swing.JPanel;
 
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.Point;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
public class pp {
 
	private JFrame jFrame = null;  //  @jve:decl-index=0:visual-constraint="104,20"
	private JPanel jContentPane = null;
	private JButton jButton = null;  //  @jve:decl-index=0:visual-constraint="85,103"
	pp()
	{
		getJFrame();	
	}
	private JFrame getJFrame() {
		if (jFrame == null) {
			jFrame = new JFrame();
			jFrame.setSize(new Dimension(400, 198));
			jFrame.setContentPane(getJContentPane());
			jFrame.setVisible(true);
		}
		return jFrame;
	}
 
	/**
         * This method initializes jContentPane 
         *      
         * @return javax.swing.JPanel   
         */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add( getJButton(),null);
		}
		return jContentPane;
	}
 
	/**
         * This method initializes jButton      
         *      
         * @return javax.swing.JButton  
         */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setSize(new Dimension(110, 39));
			jButton.setText("ffffffffff");
			jButton.setLocation(new Point(119, 55));
			jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					try {
					    File yourFile;
					    AudioInputStream stream;
					    AudioFormat format;
					    DataLine.Info info;
					    Clip clip;
 
					    stream = AudioSystem.getAudioInputStream(new File("C:/fin.mp3"));
					    format = stream.getFormat();
					    info = new DataLine.Info(Clip.class, format);
					    clip = (Clip) AudioSystem.getLine(info);
					    clip.open(stream);
					    clip.start();
					}
					catch (Exception e1) {
					    //whatevers
					}
				}
			});
 
		}
		return jButton;
	}
 
	public static void main(String[] args) {
		new pp();
 
	}
 
 
}
mais ça ne marche pas