Hi
I am trying to write a GUI program to display three buttons with three different artists name on them. If one presses a button an image should appear on the button by the name and short audio clip comes up. I am posting my code, plz check it out. If you would help that would be great.
Code:
public class myGUI extends JFrame {
private JButton myButton = new JButton("Vivaldi"); // Create a new button
private JLabel labelWithText = new JLabel();
private JButton my1Button = new JButton("Brubeck"); // Create a new button
private JLabel label1WithText = new JLabel();
private JButton my2Button = new JButton("dsf"); // Create a new button
private JLabel label2WithText = new JLabel();
private java.net.URL speakerImage= getClass().getResource("speaker.jpg");
private int status = 1; // 1 = image on, 0 = image off
// Constructor
public myGUI() {
setLayout(new GridLayout(3, 0, 0, 0)); // Define layout as a grid
add(myButton); // Make button appear in window
add(labelWithText);
add(my1Button); // Make button appear in window
add(label1WithText);
add(my2Button); // Make button appear in window
add(label2WithText);
myButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
}
// Main method
public static void main(String[] args) {
myGUI myFrame = new HW9_11(); // Declare and create an instance of MyGUI
myFrame.setVisible(true); // Make the window visible on the screen
Audio player = new Audio();
player.play("hello.wav");
myFrame.setTitle("AA");
myFrame.setSize(300, 300);
}
}
Bookmarks