Modify the Windows and Linux resolutions in Java.

Source: Internet
Author: User

/********************

Cds.exe can be downloaded from csdn!

Http://download.csdn.net/source/3317043

Attachment Source: http://home.no/aksoftware/ 3rd, qres

********************/

Import java. Io. ioexception;
/**
*
* Modify resolution
* @ Author cmxie
*/
Public class changedisplaysettings {

Public static Boolean change (int w, int H)
{
String cmd = "";
Try {
If (windowsorlinux. getsystemtype () {// judgment system: Window System
// The attachment is the cds.exe file. This file is a small tool for encapsulated resolution modification. Directly call the input parameter.
Cmd = "cmd" + system. getproperty ("user. dir") + "/downloadfilelist/source/cds.exe/X" + W + "/y" + h;
Runtime.getruntime(cmd.exe C (CMD );
Return true;
} Else {// Linux System
// Use the xrandroid command in Linux to modify the resolution
Cmd = "xrandroid-s" + W + "X" + h;
Runtime.getruntime(cmd.exe C (CMD );
Return true;
}
} Catch (ioexception e ){
E. printstacktrace ();
Return false;
}

}
Public static void main (string [] ARGs) throws nativeexception, illegalaccessexception {

Changedisplaysettings. Change (1440,900 );
}
}

/**
* Determine the Operating System
* @ Author cmxie
*
*/
Public class windowsorlinux {

/**
* Obtain the operating system type. Optional values: true: Windows, false: Linux.
* @ Return
*/
Public static Boolean getsystemtype ()
{
String osname = system. getproperty ("OS. Name ");
If (osname! = NULL &&! "". Equals (osname )){
If (osname. Matches ("^ (? I) windows. * $ ") {// Window System
Return true;
} Else
{
Return false;
}
}
Return true;
}
}

/**************** Java storm * 63353324 Technology Alliance **************** ***/

 

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.