Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Fg 6 6. For Questions 1 to 5, consider the following code: Point 5 package javaapplication284 import javax.swing. import java.awt. import java.awt.event. public class Game
Fg 6 6. For Questions 1 to 5, consider the following code: Point 5 package javaapplication284 import javax.swing. import java.awt. import java.awt.event. public class Game extends JFrame private JButton bl,b2,b3,b4: private Container contents public Game0 t super("Play this game") contents getContentPane0: contents.setLayout(new GridLayout(2,2) bl- new JButton Button 1"); b2- new JButton("Button 2"); b3-new JButton (" Button 3") b4 new JButton ("Button 4" contents.add(b1); contents.add(b2); contents.add(b3): MyHandler mh new MyHandler0; b1.addActionListener(mh); b2.addActionListener(mh); setSize(400,400); setVisible(true); private class MyHandler implements ActionListener public void actionPerformed(ActionEvent ae) System.out.printin("Hello"); if(ae.getSource)b) System.out.println(" Hello again package javaapplication284; import javax.swing.*; public class JavaApplication284 ( public static void main(Stringll args)f Game g= new Game(); g.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started