Question: mport java.awt. * ; import java.awt.event. * ; import javax.swing. * ; public class Robot extends JFrame implements ActionListener { int x , max _

mport java.awt.*; import java.awt.event.*; import javax.swing.*; public class Robot extends JFrame implements ActionListener{ int x, max_x, min_x; JButton forwardButton, backwardButton, forwardXButton, backwardXButton; JTextArea displayTA; Container cp; Question 217 Marks With regards to the above code: 2.1.(1 mark) Set the maximum and minimum bounds using the values passed to the constructor. 2.2.(3 marks) Assign the content pane to cp and assign it the FlowLayout layout manager. 2.3.(5 marks) Create the four buttons and the text area objects. Make sure that the buttons have the appropriate text and that the text area has a width of 20 characters. public static void main(String[] args){//Create an object Robot f = new Robot("Robot Movement", 10,-10); //Make the object visible f.setVisible(true); } Robot(String title, int newMax, int newMin){//2.1 Set max_x and min_x //Set up the Frame setTitle(title); setSize(300,300); setLocation(300,300); setDefaultCloseOperation(EXIT_ON_CLOSE); //2.2 Get content pane and assign layout manager //2.3 Create and set up components //2.4 Assign action listeners //2.5 Add components to the content pane }//3.1 Methods to move robot backwards and forwards by one step //3.2 Methods to move robot backwards and forwards by multiple steps //3.3 set methods for bounds //3.4 Method to check bounds have not been exceeded. //3.5 Method to update the text area //4. actionPerformed method }}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!