Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. package javaSwing;
  2.  
  3. import java.applet.Applet;
  4. import java.applet.AudioClip;
  5. import java.awt.Color;
  6. import java.awt.event.*;
  7.  
  8. import javax.swing.*;
  9.  
  10. public class Reproducir extends JFrame implements ActionListener {
  11.  
  12. public JButton Reproducir, Pausa;
  13.  
  14. public static void main(String args[]) {
  15.  
  16. Reproducir frame = new Reproducir();
  17. frame.setBounds(0, 0, 300, 200);
  18. frame.setVisible(true);
  19. frame.setLocationRelativeTo(null);
  20. frame.setResizable(false);
  21.  
  22. }
  23.  
  24. public Reproducir() {
  25.  
  26. setLayout(null);
  27. setDefaultCloseOperation(EXIT_ON_CLOSE);
  28.  
  29. Reproducir = new JButton("Reproducir");
  30. Reproducir.setBounds(30, 55, 100, 50);
  31. Reproducir.setFocusPainted(false);
  32. add(Reproducir);
  33. Reproducir.addActionListener(this);
  34.  
  35. Pausa = new JButton("Pausa");
  36. Pausa.setBounds(155, 55, 100, 50);
  37. Pausa.setFocusPainted(false);
  38. add(Pausa);
  39. Pausa.addActionListener(this);
  40. }
  41.  
  42. @Override
  43. public void actionPerformed(ActionEvent e) {
  44.  
  45. AudioClip audio;
  46. audio = Applet.newAudioClip(getClass().getResource("/*MUSICA*/"));
  47.  
  48. if (e.getSource() == Reproducir) {
  49. audio.play();
  50. }
  51. if(e.getSource() == Pausa){
  52. audio.stop();
  53. }
  54.  
  55. }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement