In: Computer Science
Write Java code which will create a GUI window on screen. The window has one button: Doggy. When the user selects Doggy, “Bow Bow” should be printed on screen. Justify your syntax.
PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class A {
public static void main(String[] args) {
JFrame f = new JFrame();
JButton b = new JButton("DOG");
b.setBounds(50, 100, 95, 30);
f.add(b);
b.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Bow Bow");
}
}
);
f.setSize(400, 400);
f.setLayout(null);
f.setVisible(true);
}
}