Java Development Picture Browser--record

Source: Internet
Author: User

Effect

  

  

Demand analysis of design ideas

Image browsing, up/down, zoom out and other basic functions. Features you can continue to expand: thumbnails, rotations, brush changes, and more. In addition, the scaling implementation is relatively simple, so there is distortion. Design such software functions can refer to ACDSee or IrfanView and other viewing software.

Knowledge points

1. File filtering, File io:filefilter

2. File dialog box:jfilechooser(add File Filtering function)

3. Browser Main interface:jtoolbar/jmenubar/JScrollPane

4. Response event:actionlistener/abstractaction

5. Display Image:ImageIcon

Design Patterns

1. Singleton: The Business Processing class is not a stateless Java object, but rather holds the information such as the Browse directory, scale, and so on.

Specific code:

     Public Static Viewerservice getinstance () {        if (null = = Service)            {new  Viewerservice ();        }         return service;    }

2. Reflection: Create an instance by reflection, avoid if...else if.....else..., enhance the extensibility of the program.

Specific code:

1     PrivateAction getaction (String actionname) {2         Try {3             if( This. Action = =NULL) {4Action action = (action) class.forname ("crazyit.action." +5 actionname). newinstance ();6                  This. Action =Action;7             }8             return  This. Action;9}Catch(Exception e) {Ten             return NULL; One         } A}

Summarize

In the practice of in-depth study, it is important in the actual process of careful study of documents , accumulate experience, write performance (algorithm) good, design (mode) reasonable program.

Source

Https://github.com/zhaoyu1995/CrazyJava/tree/master/ImageViewer

Java Development Picture Browser--record

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.