Paper Writing Services buttons and two buttons are located at the left side of the applet. (The size of the applet here is approximately 400

Abstract
the other is a dragged point. Using these two points, draw a line in the paintComponent method, then again, call it by calling repaint() method using an object of the class that has the paintComponent method. Step 3: Define the mouseReleased method. At ts point, you will have the trd coordinate (x3, y3), the point where a mouse

You can look at the Java programs in the text book to see how comments are added to programs. You are required, but not limited, to turn in the following source files: (The Assignment7 class extends JApplet) Line.java (It extends JPanel. It needs to be completed.) You may add more classes or more methods than they are specified. (You might need them.) Swing/AWT Classes may be needed: JApplet, JButton, Container, JPanel, JRadioButton, ButtonGroup, JSplitPane, Color, Grapcs, ActionListener, Point, MouseListener, and ArrayList. You may use other classes. Write a Java program that constructs an Applet. The Applet (JApplet) of your program should contain five JRadioButtons wch a user can use to select a color to draw a line, two buttons “Undo” and “Erase”, and one drawing panel where lines can be drawn. Radio buttons and two buttons are located at the left side of the applet. (The size of the applet here is approximately 400 X 400). A user can choose a color using radio buttons to draw lines. Until the color is changed, any line will be drawn with that color. A user can move a mouse in the drawing panel and press the mouse where he/she wants to start drawing a line. The first point that a user clicks will be the starting point of the line. After a user presses the mouse, a user should “drag” the mouse until the mouse reaches to a point to determine the ending point of the line. When a user is dragging the mouse, the drawing panel should show a line using the starting point and the current point. When a user releases the mouse to finalize the ending of the line, the final line should be shown. A user can continue to draw more lines. If two lines are overlapped, the line drawn later will be shown on the top. When a user pushes the “Undo” button, the last drawn line will be erased from the drawing area. Thus if a user keeps pusng the “Undo” button, eventually all lines will be erased. When a user pushes the “Erase” button, all lines should be erased. If a user pushes the “Undo” button immediately after pusng the “Erase” button, then all erased lines should come back (re-drawn) on the drawing panel. The Line class represents a line to be drawn in the panel. It should contain at least the following instance variable: Ts class should have a constructor: public Line(int x1, int y1, int x2, int y2, Color color) where the parameters x1 and y1 are (x1,y1) coordinate of the starting point of the line, x2 and y2 are (x2,y2) coordinate of the ending point of the line, and color is the color of the line. Ts class should also contain a method: public void draw(Grapcs page) Ts method should set the color and draw the line specified by its coordinates (x1,y1) and (x2,y2). You can utilize its Grapcs object parameter and drawLine method. The CanvasPanel class extends JPanel defined in javax.swing package. Ts is where lines are drawn. The background of ts panel is wte. It must contain the following method. public void paintComponent(Grapcs page) Using the parameter, the Grapcs object, ts method will draw lines with their selected color, and coordinates. Ts can be done by calling the draw method of the Line class. Remember that ts method need to call paintComponent method defined in its parent class. Ts class can be defined as nested class witn the WholePanel class. The WholePanel class organizes all components in the applet. It extends JPanel defined in javax.swing package. It should contain at least the following instance variable: Ts class should have a constructor: public WholePanel() Ts is where all components are arranged. Add as many instance variable as you would like to ts class, and initialize them in ts constructor. One way to define ts class is to contain an object of CanvasPanel, two buttons “Undo”, and “Erase”, and objects of JRadioButton to choose colors. The ButtonListener class implements ActionListener interface defined in java.awt.event package. It must implement the following method: public void actionPerformed(ActionEvent event) In ts method, the action to be performed in case one of “Undo”, and “Erase” button is pushed. Ts listener is used with JButtons. The ColorListener class implements ActionListener interface defined in java.awt.event package. It must implement the following method: public void actionPerformed(ActionEvent event) In ts method, the color selected by using the JRadioButtons is assigned as a color to be used to draw a line. Ts listener is used together with JRadioButtons. The PointListener class implements MouseListener interface and MouseMotionListener interface. It must implement the following method: public void mousePressed(MouseEvent event) When a user presses a mouse, that point is defined as the starting point of a line to be drawn. You might call ts pressed point’s coordinate . public void mouseDragged (MouseEvent event) After a user presses a mouse and drags it, a line needs to be drawn using the starting point and the current coordinate as the ending point of the line. You might call ts dragged point’s coordinate . As long as a mouse is not released yet (still dragging), then the line will keep changing. public void mouseReleased(MouseEvent event) When a user releases a mouse, a line needs to be drawn using the released point as the final point of the line. You might call ts released point . Other methods from MouseListener and MouseMotionListener can be left as blank. Note that these tree listener classes and CanvasPanel class can be defined as nested classes inside of the WholePanel class. Download the following files and use them as a base of your program: Step 0: Define Line class in the Line.java file. There are only two methods in ts class, and they are straight forward. Step 1: Complete WholePanel.java file. Define the mousePressed method to get the point that a mouse is pointing. Use the point where the mouse is pushed to get its (x,y)-coordinate. Step 2: Define the mouseDragged method. At ts point, you will have two coordinate (x1,y1) and (x2,y2), one is a pressed point and the other is a dragged point. Using these two points, draw a line in the paintComponent method, then again, call it by calling repaint() method using an object of the class that has the paintComponent method. Step 3: Define the mouseReleased method. At ts point, you will have the trd coordinate (x3, y3), the point where a mouse is released. Instantiate an object of Line class, by passing its starting point (x1,y1), its ending point (x3,y3), and its color. At ts point, the color is just black by default. Since there will be many lines created, we can use an ArrayList called “lineList” to add an object of Line. Step 4: Define the paintComponent method to draw all lines in the lineList. You need a loop to do ts. Step 5: Add the “Undo” and “Erase” buttons, and create ButtonListener class to implement actionPerformed method. “Undo” will delete the last line, so you need to do sometng with the lineList and re-draw. “Erase” will delete all lines. Step 6: Add the JRadioButtons to select colors and also create ColorListener to implement actionPerformed method. More steps: These are just skeletons. You need to adjust your code to make it work cleanly.

Sample references
  • (‘Changnon, S. 1969. Recent studies of urban effects on precipitation in the U.S. Bulletin of the American Meteorological Society 50(6): 411-421.’,)
  • (‘Janetos, A., L. Hansen, D. Inouye, B. P. Kelly, L. Meyerson, B. Peterson, and R. Shaw. 2008. Biodiversity. In The Effects of Climate Change on Agriculture, Land Resources, Water Resources, and Biodiversity in the United States. Washington, DC: Climate Change Science Program.’,)
  • (‘Barker, T., I. Bashmakov, A. Alharthi, M. Amann, L. Cifuentes, J. Drexhage, M. Duan, O. Edenhofer, B. Flannery, M. Grubb, M. Hoogwijk, F. I. Ibitoye, … (224 characters truncated) … nel on Climate Change. B. Metz, O. R. Davidson, P. R. Bosch, R. Dave, and L. A. Meyer, eds. Cambridge, U.K. and New York: Cambridge University Press.’,)
  • (‘Sackett, DL. (2000). Evidence-based medicine. New York: John Wiley ‘,)

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer