Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago