Question: this is java language could you please answer this as soon as possible a) create a class that will be called New, it should have
this is java language
could you please answer this as soon as possible
a) create a class that will be called New, it should have private member variables name of type String, c of type Color and x, y, width, height of type int.
create a class called NewGUI that inherits from JComponent.
b)For this part add a constructor which will sets all member variables of this class via provided parameters. You should then add a method called makeLabel that will receive Graphic objects as parameters and then draws a rectangle on this object using the corresponding values from the member variables, i.e. a rectangle of colour c, width width, height height, coordinate x y with the String name within the rectangle.
c)Add a data structure of your choice to NewGUI that can contain New objects. Add a mouse listener to NewGUI. Upon a left click check if the clicked coordinate is within one of the labels. If so print this label to the command line. Upon a right click prompt the user (e.g. via the command line) to enter the name of a new label. Create the label at the coordinates of the click with a width and height that allows the label the user entered to fit within the boundaries of the rectangle (this does not have to be exact to the last pixel, nonetheless the size should scale with the label). You can choose the colour you want to use for your labels (it does not have to be specified by the user via the command line). Override the paintComponent method in NewGUI. In this method you should draw all the New objects in your data structure. Add a class called Exercise with a main method. In this method create a JFrame object and display your NewGUI within this frame. Make sure to program terminates when the window is closed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
