Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please only use whats said to use , no more no less , ty. Create a drawing JFrame application that draws lines, rectangles, and ovals.

Please only use whats said to use , no more no less , ty. image text in transcribed
Create a drawing JFrame application that draws lines, rectangles, and ovals. For this purpose, create a set of JPanel's shape classes MyLine, MyRect, and MyOval. The data for class MyLine should include x1, y1, x2, and y2 coordinates. Method drawLine of class Grahpies is used to connect the two points to draw the line. The data of classes MyRect and MyOval should include the upper-left-x-coordinate value, an upper-left-y- coordinate value, a width (non-negative) and a height (non-negative). All data in each class must be private. In addition to the data, each class should define at least the following methods: a) A constructor with no arguments that sets the coordinates to 0. b) A constructor with arguments that sets the coordinates to the supplied values. c) Set methods for each individual piece of data that allows the programmer to modify any piece of data in a shape (i.e. if you have a variable xl then you should have a method setX1). d) Get methods for each individual piece of data that allows the programmer read any piece of data in a shape (i.e. if you have a variable xl then you should have a method getXI) e) A draw method with the first line: public void paintComponent (Graphics g that is responsible of drawing its corresponding shape, and it would be called by JPanel draw a shape on the screen. In your JFrame application, you should ask the user for a shape to draw (oval, line, or rectangle). The application generate the coordinates and dimensions randomly (horizontally between 0 and getWidth0/2 and vertically between 0 and getHeight0/2), and utilizes the class to draw the requested shape

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

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago