Question

In: Computer Science

Write Java code which will create a GUI window on screen. The window has one button:...

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.

Solutions

Expert Solution

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class BowBowGUI {  
static    JFrame frame = new JFrame("JFrame Example");  
        
public static void main(String s[]) {  
        JPanel panel = new JPanel();  
        panel.setLayout(null);  
        final JLabel label1 = new JLabel("");  
        label1.setBounds(200, 50, 400, 30);
        
        JButton doggy = new JButton();  
        doggy.setText("Doggy");  
        doggy.setBounds(200, 150, 100, 20);

        doggy.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e)
            {
                label1.setText("Bow Bow");
            }
        });
        panel.add(doggy);
        panel.add(label1);
        frame.add(panel);
        frame.setSize(600, 300);  
        frame.setLocationRelativeTo(null);  
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
        frame.setVisible(true);  
    }  
}  

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME


Related Solutions

Write Java code which will create a GUI window on screen. The window has one button:...
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.
Write Java code which will create a GUI window on screen. The window has one button:...
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.
Write Java code which will create a GUI window on screen. The window has one button:...
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.
Write Java code which will create a GUI window on screen. The window has one button:...
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.
Write Java code which will create a GUI window on screen. The window has one button:...
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.
Write Java code which will create a GUI window on screen. The window has one button:...
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.
Write Java code which will create a GUI window on screen. The window has one button:...
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.  
Write Java code which will create a GUI window on screen. The window has one button:...
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. ASAP
Write Java code which will create a GUI window on screen. The window has one button:...
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.
Write Java code which will create a GUI window on screen. The window has one button:...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT