Eclipse rap rich client Development Summary (10)-differences between rap systems and Handling Methods

Source: Internet
Author: User

Note: Eclipse rap rich client Development Summary-a series of articles are transplanted from my iteye blog. Later will directly update the http://jlins.iteye.com/

Normally, rap program development is generally completed under win, and then tested under tomcat, but the final release of the program is generally on Linux Aix. At this time, problems may occur, the following two problems are the problems we have encountered during development. Let's share them with you;

1. Image path

This is the most common method, that is, loading images in rap for display. At first we used the following code:

 

public static String getRoot() {        String path = null ;        try {     path = FileLocator.toFileURL (Platform.getBundle (Activator. PLUGIN_ID ).getEntry( "" )).getPath();     path = path.substring(path.indexOf( "/" ) + 1, path.length());        }        catch (Exception e) {           log .error( "getRoot method :" , e);        }        return path;    }

To obtain the path of the system. But when the program is transplanted to Linux and Aix, it finds that all the image paths are invalid. You can use the following method for addressing to obtain the image.

/*** Get image ** @ Param filename * image name * @ return first searches for the cached object. If yes, the image is directly returned. If no, the image is loaded into the cache, transmit the image from the cache to call */public static image getimage (string filename) {bundle = platform. getbundle ("telecomui"); Url url = bundle. getentry ("icons"); try {url = platform. aslocalurl (URL);} catch (exception e) {} image = registry. get (filename); If (null! = Image) {return image;} else {URL fullpathstring = bundle. getentry ("icons/" + filename); imagedescriptor des = imagedescriptor. createfromurl (fullpathstring); registry. put (filename, des); Return imagedescriptor. createfromurl (fullpathstring ). createimage ();}}

2. Obtain the screen resolution

This is because you need to center some pop-up components and obtain the system resolution.

At the beginning, we used the following method;

screenH = Toolkit.getDefaultToolkit().getScreenSize ().height;        screenW = Toolkit.getDefaultToolkit().getScreenSize ().width; 

The above code is correct under the window, but an error is reported under Linux and Aix and cannot be found.

Sun. AWT. x11.xtoolkit class

You can use the following method to obtain the screen resolution:

DisPlay.getDefault().getClientArea();

3. Others will be added if any incompatibility is found

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.