(Solved) : Using Java Language Assume Graphical User Interface Bunch Rectangles Added Randomly Screen Q42701243 . . .

Using java language

Assume you have a graphical user interface with a bunch ofRectangles that you added

randomly all over the screen, and saved in anArrayList<Rectangle> called

rectangles. The built-in Rectangle shape class is notimplemented to be Comparable,

but you want to be able to sort the rectangles in order of howthey appear in the interface from

left to right. If two Rectangles align on the left, theRectangle up higher in the interface should

come first. Note: the built-in Rectangle class has methodsgetX(), getY(),

getWidth(), and getHeight(), all of which return a double. Writeyour own comparator

so that you can use the following line to sort yourRectangles:

Collections.sort(rectangles, new MyRectangleComparator());

—————————————————————-

import java.util.Comparator;

public class MyRectangleComparator

Expert Answer


Answer to Using java language Assume you have a graphical user interface with a bunch of Rectangles that you added randomly all ov…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?