Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaSwing;
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Color;
- import java.awt.event.*;
- import javax.swing.*;
- public class Reproducir extends JFrame implements ActionListener {
- public JButton Reproducir, Pausa;
- public static void main(String args[]) {
- Reproducir frame = new Reproducir();
- frame.setBounds(0, 0, 300, 200);
- frame.setVisible(true);
- frame.setLocationRelativeTo(null);
- frame.setResizable(false);
- }
- public Reproducir() {
- setLayout(null);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- Reproducir = new JButton("Reproducir");
- Reproducir.setBounds(30, 55, 100, 50);
- Reproducir.setFocusPainted(false);
- add(Reproducir);
- Reproducir.addActionListener(this);
- Pausa = new JButton("Pausa");
- Pausa.setBounds(155, 55, 100, 50);
- Pausa.setFocusPainted(false);
- add(Pausa);
- Pausa.addActionListener(this);
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- AudioClip audio;
- audio = Applet.newAudioClip(getClass().getResource("/*MUSICA*/"));
- if (e.getSource() == Reproducir) {
- audio.play();
- }
- if(e.getSource() == Pausa){
- audio.stop();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement