201521123088 Java Programming 6th Week of study summary

Source: Internet
Author: User
Tags event listener

1. Summary of this week's study

2. Written work
  1. Clone method
    1.1 Object in theclonemethod is modified by protected, what do you need to be aware of when overriding the Clone method in your custom class? Answer: OverwriteThe Clone method first sets the property to public .
    1.2 When you design your own class, what kind of method is generally used to modify the protected? Take the job Shape as an example.                          ,         &NB Sp                          ,         &NB Sp                           A: PR Otected modified variables, subclasses can directly access the parent class members or quilt class overrides. In the shape, the amount of abstraction associated with the graph, such as the length and width of the height, can be protected.
    1.3 Write a simple Employee class in the Test1 package, create a new testprotected class in the Test2 package, And in main, try to invoke the Clone method of the employee in the Test1 package to clone a new object, can it be successful?          A : Failure, because the Clone method is protected decorated, and protected is modified only in the subclass and in the same package access.

  2. Overriding a topic with an anonymous class and a lambda expression object-oriented 2-advanced-the problem of the inner class of a polymorphic interface 5-2
    Just paste the key code and run the results, the picture is not too large. For:

  3. Analyze the following code to answer shapeComparator what does the object pointed to have to do with the comparator interface?

    New  Comparator<shape>() {       @Override       publicint  Compare (Shape O1, shape O2) {            // Your code            }         };

  4. Event handling in the GUI
    4.1 Write out the most important keywords in the event-handling model. Answer: event, event source, event listener
    4.2 Use code and annotations to prove that you understand the event-handling model. For:

     Public classEventObjectImplementsjava.io.Serializable {protected transientObject Source;  PublicEventObject (Object source); PublicObject GetSource ();//Get Event Source     PublicString toString ();} Public classMaingui { Public Static voidMain (string[] args) {JFrame F=NewJFrame ("Test");//Create an Event templatef.setdefaultcloseoperation (jframe.exit_on_close); JButton b=NewJButton ("Press me!");//Event SourceB.addactionlistener (NewButtonhandler ());//Registering event ListenersF.add (b); F.setsize (200, 100); F.setvisible (true); }    Private Static classButtonhandlerImplementsactionlistener{//Listener     Public voidactionperformed (ActionEvent e) {System.out.println ("Action occurred"); System.out.println (E.getsource ());//Get Event Source    }   }} 

    3. Code submission record on code Cloud and PTA Experiment Summary
  5. Pair programming: Object-oriented design (big job 2-very important, unfinished-2)
    Continue to refine last week's project assignments. The assessment points are as follows:
    5.1 Try overwriting using the graphical interface.
    5.2 Gives a record of the same item on the code cloud for two people.
    5.3 What are the major changes to the project compared to last week?

Pair programming Reference
Drawing with ProcessOn
Video-writing a GUI with NetBeans
Important: Swing Experimental reference
JTable usage, for rendering tabular data
Swing related articles

3. Code submission record on code Cloud and PTA Experiment Summary

Topic set: jmu-java-04-Object-oriented 2-advanced-polymorphic interface inner class

3.1. Code Cloud codes Submission record

3.2. PTA Experiment

1. Learned to define an interface. 2. Learn how to create a static inner class and its methods inside a class.

201521123088 Java Programming 6th Week of study summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.