Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import javax.swing.border.*;
- import java.awt.*;
- import java.awt.event.*;
- import java.lang.*;
- public class sound extends JFrame implements ActionListener {
- public sound() {
- //makes the frame
- setTitle("Click it!");
- setSize(200, 200);
- setResizable(false);
- setLocationRelativeTo(null);
- setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- //get content pane
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //make the button
- JButton button = new JButton("Click me!");
- button.setBounds(50, 50, 100, 50);
- button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- public void run() {
- JOptionPane.showMessageDialog(null, "It works!");
- }
- }
- });
- contentPane.add( button );
- }
- public static void main (String [] args) {
- sound frame = new sound();
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment