java assignment 24

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


Order a Similar Paper Order a Different Paper

you are going to use Inheritance and Interfaces on one class you write to create a window that when clicked on swaps colors of the window. Similar to the video I put up last week.

Create a new project called MyInheritanceFrame.

  • Have your class inherit from JFrame (import the proper libraries).
  • In public static main create an instance of your class (your class that is inheriting from JFrame)
    • Send in a String to the constructor of your class and then pass it on to JFrame so when the frame is shown it has the String as the title “232 Frame” (like in my images below).
    • Set the size of the frame to 300, 600 (inherited method) in your constructor.
    • Add this line in your constructor: setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    • create a JPanel — “new JPanel()” this JPanel should be an instance field so you can change it later.
    • Set the background color of the panel to yellow
      • You need to find out how to set the color and create a new instance of the Color class with 255, 255, 0
    • add the panel to the contentPane of your frame — getContentPane().add(
    • this will give you the contentPane and the first part of the add method, add it using default layout….which means you just have to add it, nothing else.
    • In your constructor make the frame visible calling the method you inherited that will make it visible.
  • Run your program and you should see something exactly like this:

Now we will add a MouseListener to the code.

  • Add a MouseListener interface to your class that inherits from JFrame
  • Include all the methods needed to get this to compile.
    • Since MouseListener is an interface you have to include all the methods it’s requiring, look them up, they can be {} = blank, but they have to be there.
  • In the mouseReleased method add code to change the background color from yellow to a new color, and use random generated colors, RGB colors 0-255 randomly generated. Each time you click it should change colors.
    • new Color(red, gree, blue)
    • red, green and blue are Random generated numbers 0-255
  • When the mouse leaves the frame it should always go back to yellow, different interface method

Here are screen captures of my window showing the result after three clicks and then the mouse exiting.

"Is this question part of your assignment? We can help"

ORDER NOW
Writerbay.net

Do you need help with this or a different assignment? We offer CONFIDENTIAL, ORIGINAL (Turnitin/LopesWrite/SafeAssign checks), and PRIVATE services using latest (within 5 years) peer-reviewed articles. Kindly click on ORDER NOW to receive an A++ paper from our masters- and PhD writers.

Get a 15% discount on your order using the following coupon code SAVE15


Order a Similar Paper Order a Different Paper