Flex gets IP and Pcname sample code through Java background _flex

Source: Internet
Author: User
The code in ***daoimpl.java is as follows
Copy Code code as follows:

Public String Getcompuname ()
{
map<string, string> map = system.getenv ();
String computerName = Map.get ("ComputerName");//Get Computer name
return computerName;
}
Public String GetIP ()
{
InetAddress addr = null;
try {
addr = Inetaddress.getlocalhost ();
}
catch (Unknownhostexception e)
{
E.printstacktrace ();
}
String IP = addr.gethostaddress (). toString ();//Get native IP
return IP;
}

Need to introduce
Copy Code code as follows:

Import Java.util.Map;
Import java.net.InetAddress;
Import java.net.UnknownHostException;

Flex Foreground Code
Copy Code code as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<s:application xmlns:fx= "http://ns.adobe.com/mxml/2009"
Xmlns:s= "Library://ns.adobe.com/flex/spark"
xmlns:mx= "Library://ns.adobe.com/flex/mx" xmlns:supportclasses= "com.esri.ags.skins.supportclasses.*" minWidth= " 955 "minheight=" creationcomplete= "init ()" >
<fx:Script>
<! [cdata[
Import Mx.controls.Alert;
Import mx.rpc.events.FaultEvent;
Import mx.rpc.events.ResultEvent;
Public function init (): void
{
Ipandpcname.getcompuname ();
Ipandpcname.getip ();
}
Public Function Ipandpcname_faulthandler (event:faultevent): void
{
Alert.show (Event.tostring ());
}
Public Function Getcompuname_handler (event:resultevent): void
{
Alert.show (Event.result.toString ());
}
Public Function Getip_handler (event:resultevent): void
{
Alert.show (Event.result.toString ());
}
]]>
</fx:Script>
<s:layout>
<supportClasses:AttachmentLayout/>
</s:layout>
<fx:Declarations>
<!--place non-visual elements (such as services, value objects) here-->
<mx:remoteobject id= "Ipandpcname" destination= "systemconfaction" fault= "Ipandpcname_faulthandler" (event) >
<mx:method name= "Getcompuname" result= "Getcompuname_handler (event)"/>
<mx:method name= "GetIP" result= "Getip_handler (event)"/>
</mx:RemoteObject>
</fx:Declarations>
</s:Application>
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.