Robot API and Color API

I have been writing this program for a while now. In its current incarnation it has been pulling up several errors consistently.
First, is there any way I can use the String boing = myRobot.getPixelColor(x, y).toString(); line that is commented out? Whenever I enter data it throws a null pointer exception.
Second, why is it putting 25 into the temp[ ] array instead of 255? It places 255 into the first slot but 25 in the second and third slot. What can I do to pull the whole number out of the string.
Thank you. Any help that can be given is very much appreciated.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.image.*;
import java.awt.Robot;
import java.awt.Color;
public class GetColor extends JFrame implements ActionListener
         JButton submit = new JButton("Submit");
         JTextField xcoor = new JTextField(5);
         JTextField ycoor = new JTextField(5);
         JLabel xlbl = new JLabel("X coordinate: ");
         JLabel ylbl = new JLabel("Y coordinate: ");
         JLabel hxlbl = new JLabel("Hexadecimal value: ");
         JPanel panA = new JPanel();
         JPanel panB = new JPanel();
         JPanel panC = new JPanel();
         JPanel panD = new JPanel();
         JTextField hex = new JTextField(25);
         Robot myRobot;
  public GetColor()
         getContentPane().setLayout(
              new BoxLayout(getContentPane(), BoxLayout.Y_AXIS ));
         panA.add(xlbl);
         panA.add(xcoor);
         panB.add(ylbl);
         panB.add(ycoor);
         panC.add(hxlbl);
         panC.add(hex);
         panD.add(submit);
         getContentPane().setLayout(
              new BoxLayout( getContentPane(), BoxLayout.Y_AXIS ));
         getContentPane().add(panA);
         getContentPane().add(panB);
         getContentPane().add(panC);
         getContentPane().add(panD);
         submit.addActionListener(this);
         submit.setActionCommand("Submit");
         hex.setEditable(false);
  public void actionPerformed(ActionEvent evt)
         String userInA, userInB;
         int x, y;
         userInA = xcoor.getText();
         x = Integer.parseInt(userInA);
         userInB = ycoor.getText();
         y = Integer.parseInt(userInB);
         int rgb[] = new int[3];
         String temp[] = new String[3];
          String arr[] = new String[3];
         String blah = "#";
          String boing = "java.awt.Color[r=255,g=255,b=255]";
        //  String boing = myRobot.getPixelColor(x, y).toString(); //java.awt.Color[r=xxx,g=xxx,b=xxx]
         String heynow;
         heynow = boing.substring(14, boing.length());
         StringBuffer sb = new StringBuffer(heynow);
         System.out.println(sb);
          temp[0] = sb.substring(sb.indexOf("=")+1, sb.indexOf(","));
          System.out.println(temp[0]);
          sb.delete(sb.indexOf("="), sb.indexOf(",")+1);
         System.out.println(sb);
          temp[1] = sb.substring(sb.indexOf("=")+1, sb.indexOf(",")-1);
          System.out.println(temp[1]);
         sb.delete(sb.indexOf("="), sb.indexOf(",")+1);
         System.out.println(sb);
          temp[2] = sb.substring(sb.indexOf("=")+1, sb.indexOf("]")-1);
          System.out.println(temp[2]);
          sb.delete(sb.indexOf("="), sb.indexOf("]"));
          System.out.println(sb);
          rgb[0] = Integer.parseInt(temp[0]);
          rgb[1] = Integer.parseInt(temp[1]);
          rgb[2] = Integer.parseInt(temp[2]);
         for(int i = 0; i<3; i++){
              arr[i] = Integer.toHexString(rgb);}
for(int a = 0; a<3; a++){
blah.concat(arr[a]);}
try{
myRobot = new Robot();
}catch(AWTException awtex){}
if(evt.getActionCommand().equals("Submit"))
panA.setBackground( myRobot.getPixelColor(x, y) );
panB.setBackground( myRobot.getPixelColor(x, y) );
panC.setBackground( myRobot.getPixelColor(x, y) );
panD.setBackground( myRobot.getPixelColor(x, y) );
hex.setText(blah);
repaint();
public static void main ( String[] args )throws AWTException
GetColor frm = new GetColor();
WindowQuitter wquit = new WindowQuitter();
frm.addWindowListener( wquit );
frm.setSize( 350, 250 );
frm.setVisible( true );
frm.setTitle("Pixel Color");
class WindowQuitter extends WindowAdapter
public void windowClosing( WindowEvent e )
System.exit( 0 );

The NullPointerException comes from the fact you never created a Robot instance.
you might also change this junk
if(evt.getActionCommand().equals("Submit"))
              panA.setBackground( myRobot.getPixelColor(x, y) );
              panB.setBackground( myRobot.getPixelColor(x, y) );
              panC.setBackground( myRobot.getPixelColor(x, y) );
              panD.setBackground( myRobot.getPixelColor(x, y) );
              hex.setText(blah);into this
if(evt.getActionCommand().equals("Submit")) {
              panA.setBackground( myRobot.getPixelColor(x, y) );
              panB.setBackground( myRobot.getPixelColor(x, y) );
              panC.setBackground( myRobot.getPixelColor(x, y) );
              panD.setBackground( myRobot.getPixelColor(x, y) );
              hex.setText(blah);
}Note the brackets...

Similar Messages

  • JAVA API AND ABAP API SIMPLE SCENARIO

    Hello MDM gurus
    I have never used any Java API or ABAP API to leverage and present MDM functionalities on front end systems like portal,etc...
    Could you please give me all the required to play around with JAVA api and ABAP api's.
    Points will be given to every valuable answer.
    Thanks

    Hi Nazeer,
    In order to use Portal you need Java APIs and to start with refer the MDM Java docs to get the basic idea of various classes and methods to be used in developing the simple java application and access it using portal.
    http://help.sap.com/saphelp_mdm550/helpdata/en/47/9f23e5cf9e3c5ce10000000a421937/frameset.htm
    Sample code for Duplicating Repository
    public class TestDuplicateRepository
               public static ConnectionPool simpleConnection;
               public static RepositoryIdentifier repIdentifier,repIdentifier1;
         public static String session;
         public static String connection = "MDMServer_Test";
         public static String repository1 = "Test_Repository";
         public static String repository2 = "Test_Duplicate";
              public static DBMSType dbmsType = DBMSType.MS_SQL;
         public static void main(String[] args)throws CommandException, ConnectionException
                   //Creating Connection.
                   simpleConnection = ConnectionPoolFactory.getInstance(connection);     
                   //Establishing connection with Repository.
                   repIdentifier = new RepositoryIdentifier(repository1, connection, dbmsType);
                   repIdentifier1 = new RepositoryIdentifier(repository2, connection, dbmsType);
                   //Creation Sever Session.
                   CreateServerSessionCommand createServerSessionCmd = new CreateServerSessionCommand(simpleConnection);
                   createServerSessionCmd.execute();
                   session = createServerSessionCmd.getSession();
                   //Authenticating Server Session.                    
                   AuthenticateServerSessionCommand auth= new AuthenticateServerSessionCommand(simpleConnection);
                   auth.setSession(session);
                   auth.setUserName("Admin");
                   auth.setUserPassword("Admin");
                   auth.execute();
                   session = auth.getSession();     
                   //Duplicate Repository Command
                   DuplicateRepositoryCommand duplRepCmd = new DuplicateRepositoryCommand(simpleConnection);
                   duplRepCmd.setDBMSUserName("sa");
                   duplRepCmd.setDBMSUserPassword("abc");
                   duplRepCmd.setSession(session);
                   duplRepCmd.setSourceRepositoryIdentifier(repIdentifier);
                   duplRepCmd.setTargetRepositoryIdentifier(repIdentifier1);
                   duplRepCmd.execute();
    Similarly you can try with Getting server version, Archive repository and then move on to adding,modifying records etc.
    For ABAP APIs refer the below link
    http://help.sap.com/saphelp_mdm550/helpdata/en/44/93aa6e31381053e10000000a422035/frameset.htm
    Regards,
    Jitesh Talreja

  • BPM 11g: JAVA API and Webservice API

    Who knows BPM 11g: JAVA API and Webservice API?
    Customer want to call BPM 11g between Heterogeneous systems, such .net framework. One way is use webservice API, I think, but where can find it? thank you

    When you create a BPM application in 11g, you're actually creating a SOA composite application with a BPMN component in the composite. From within the BPMN editor, you can specify the interface (parameters) of each start node in the process. If you select a start node, look at the implementation tab, you'll see a properties group that lets you define the interface one property at a time, or by selecting an interface from the catalog.
    By defining these properties you're also defining the shape of the Web Service interface that will automatically be created in the composite. If you switch to the composite view, you'll see your BPMN process with a wire to it from a Web Service that's generated from the interface defined in the BPMN editor. The naming convention is the BPMN process name with ".service" appended. When you deploy the BPMN process, the web service will also be deployed, since it's also part of the composite. From Enterprise Manager (EM) you can test the service and get the WSDL, which could be used by other applications (e.g. .NET) to start and interact with a process instance.
    This is one of the advantages of the 11g architecture. The composite exposes services to consumers/clients. The implementation could have been BPEL, BPMN, a Mediator, Java/EJBs, or any combination working together. To the consumer, it's just a web service.
    In case your next question was about security ... you won't see properties about security in the BPMN editor. You use Web Service Manager to apply security or other constraints to the web service endpoint.

  • What is the difference between private API and public API??

    Hi,
    I came accross the terms private API and Public API ?
    what are these APIs and what is the difference between them??
    Thanks and Regards,
    Soham

    Soham,
    Publicly Callable Business Process APIs are the list of supported and published APIs. Direct calls to any other routines are not supported, unless explicitly specified, because API validation and logic steps will be bypassed. Many other packages include procedures and functions, which may be called from the API code itself.
    Note:216838.1 - Oracle HRMS Product Family Publicly Callable Business Process APIs (A Reference Consolidation)
    Regards,
    Greg

  • [svn:bz-trunk] 20695: Tomcat 7 Valve/ LoginCommand changes due to the ValveBase API and Realm API change.

    Revision: 20695
    Revision: 20695
    Author:   [email protected]
    Date:     2011-03-08 13:32:45 -0800 (Tue, 08 Mar 2011)
    Log Message:
    Tomcat 7 Valve/LoginCommand changes due to the ValveBase API and Realm API change.
    rename valve name as Tomcat7Valve
    will need to merge the build.xml after the build machine can fork a JDK 1.6 build
    Checkintests pass
    Modified Paths:
        blazeds/trunk/modules/opt/build.xml
    Added Paths:
        blazeds/trunk/modules/opt/src/tomcat/flex/messaging/security/Tomcat7Valve.java
    Removed Paths:
        blazeds/trunk/modules/opt/src/tomcat/flex/messaging/security/TomcatValve708.java

  • Not Showing the UI API and DI API reference

    Hi Experts,
    I have SAPB1 8.81 pl 5.  I have also installed the sdk 8.81 pl5 but when i am opening my .Net project in visual studio 2008 the older refence to ui api and di api is showing some warning so i have just remove both the references and try to add new reference to ui api and di api.
    My problem is that when i am clicking on add refernce it is not showing the 8.81 versions in the list and if i am taking the reference of 8.8 only then it's again giving the warning symbol as previous .

    I am assuming that when you try to add the Reference in VS, that for SAP Business One you are choosing the COM tab.  You should see the Component Name as SAP Business One DI API Version 8.81, but the TypeLib Version will still say 8.8 ... this would be the same for the UI API.
    Possibly you want to uninstall the SDK, make sure the directories are removed and then re-install.
    Eddy

  • How could JAVA API and ABAP API useful to MDM.

    Hi Experts,
    How could JAVA API and ABAP API useful to MDM, and any coding in Java or ABAP is required in MDM.

    Hi Reema,
    Java API and ABAP API are verry usefull to MDM to integrate MDM with other SAP componants like SAP R\3, EP etc. :
    It dose not required any coding in MDM infact in JAVA API coding can be done on NWDS(Netweaver Developer Studio).And for ABAP API coding is done on SAP R\3 System in ABAP editor.
    JAVA API:
    By using Java API MDM client operations can be performed.For one need to install NWDS and to deploy some .jar files and with the help of standard classes and interfaces it can be connected to MDM server and various operations like create repository ,connect to repository ,Data mainuplation etc.
    ABAP API:
    Suppose you have an Expert abaper and you want him to perform MDM operations.In that case he need not to learn MDM basic Data types infact by doing some settings on R\3 and MDM server side an ABAPer  can perform
    MDM Cnsole and MDM Data Manager level operations.
    you can go through these links
    http://help.sap.com/javadocs/MDM/SP06/overview-summary.html
    /people/bv.pillai/blog/2006/11/28/installing-mdmtech-add-on-and-configuring-the-mdm4a-mdm-for-abap-api
    Here the coding is done on SAP R\3 system.
    hope it will give you some idea about Java API and ABAP API
    Reward if helpful
    Thanks ,
    Vinay Yadav

  • Private API and Public API

    What is the difference between private API and public API??

    Hello,
    from a technical point of view, a private API is normally embedded in a public API.
    The NON ORACLE specialist developpers have to use public API as an interface to control ORACLE APPLICATIONS.
    Normally, the functions/procedures of private API must be hidden to the NON ORACLE specialist developper.
    Roméo.

  • Publib API and Private API

    What is the difference between private API and public API??

    Hello,
    from a technical point of view, a private API is normally embedded in a public API.
    The NON ORACLE specialist developpers have to use public API as an interface to control ORACLE APPLICATIONS.
    Normally, the functions/procedures of private API must be hidden to the NON ORACLE specialist developper.
    Roméo.

  • Difference between CE_BANK_PUB API and iby_ext_bankacct_pub API

    Hi All,
    Could you please tell me what is the difference between CE_BANK_PUB API and iby_ext_bankacct_pub API?
    Which scenario we have to use those API's?
    Thanks in Advance
    Thanks
    Lakshminarayana

    Hi Hussein
    Thanks for your replay.
    Yes I have followed the Note but getting error. Using the note I have created Bank and Branch but when I am going to create account getting error message that I have putted the error message earlier.
    Thanks
    Makshud

  • What is the relationship of javatv api,jmf api and mhp api ?

    Whether all these three set of API are required to write digital tv program?

    That depends on what the digital TV program (I assume you mean MHP application) wants to do. Specifically;
    - javax.tv.xlet.Xlet is needed whatever you want to do.
    - Most of the rest of JavaTV is only needed if you want to write an electronic program guide, e.g. to get at service information.
    - If you want to write a program which manipulates the video & audio of the TV signal then you need the JMF API and also a small part of javax.tv.service.selection to get hold of the JMF player for the running TV content.
    - The MHP APIs do many different things, again depending on what your application wants to do.
    - You don't mention them but you also probably need some of the org.havi.ui APIs. In MHP, the top level graphics Container class for applications is an instance of org.havi.ui.HScene. Also the "VK_" constants for some of the remote control codes are only defined in org.havi.ui.HRcEvent.
    See http://www.mhp-interactive.org for examples of how to use many of the MHP APIs.

  • DatagramSocket API and ServerSocket API

    Based on the release notes of 11.8, the DatagramSocket APIs is now supported on iOS.
    This API is not in the playerglobal.swc available for download @ http://labsdownload.adobe.com/pub/labs/flashruntimes/flashplayer/flashplayer11-8_playerglo bal.swc
    How can I access this API ?
    Reference: http://labsdownload.adobe.com/pub/labs/flashruntimes/shared/air3-8_flashplayer11-8_release notes.pdf
    Thanks.
    Guillaume

    These APIs are already present in AIR desktop.  These will not be available in Flash Player because of the security implications in the context of a web browser running untrusted/unsigned content.
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/DatagramSocke t.html
    The DatagramSocket class enables code to send and receive Universal Datagram Protocol (UDP) packets.
    AIR profile support: This feature is supported on all desktop operating systems, but is not supported on mobile devices or AIR for TV devices. You can test for support at run time using the DatagramSocket.isSupported property. See AIR Profile Support for more information regarding API support across multiple profiles.
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/ServerSocket. html
    The ServerSocket class allows code to act as a server for Transport Control Protocol (TCP) connections.
    AIR profile support: This feature is supported on all desktop operating systems, but is not supported on mobile devices or AIR for TV devices. You can test for support at run time using the ServerSocket.isSupported property. See AIR Profile Support for more information regarding API support across multiple profiles.

  • (U)SIM API and SIM API

    What is the difference between sim.toolit, sim.access and uicc.toolkit, uicc.access APIs ??? by difference i mean difference in usage and functionality ??

    The "SIM API for Java Card" is pecified in GSM 43.019, as the latest releases, nr. 5 of this specification. And this will be the last versions of this spec. You can find them on ftp://ftp.3gpp.org/specs/archive/ together with all other GSM and 3G specifications. Earlier releases where called 03.19, but they are not longer maintained in the standardization process.
    Another interesting resource to learn how 43.019 works is 51.013 the testspecification and testsuite for this spec.
    There is a new API defined the "UICC API for Java Card" ETSI TS 102 241 based on Java Card 2.2, but this was done recently and no products are availabel at the moment.
    The OTA loading of STK applets is defined in 03.48 or 23.048 as the latest version. It is based on the SMS protocoll defined in 23.040.

  • Differences between bpel client api and workflow api

    can anyone help me with the differences between the two bpel apis.
    i think the client is just to interact with the server (invoking processes and completing tags) , and the workflow is to interact with processes definitions and more deeply detail of the processes. is this true ?
    can anyone hand me some workflow api usage ?
    thanks in advance for any help

    Hi ,
    workflow apis are more to do with the taskservice which gets invoked on every human task of a bpel process.
    Client apis have more to do with metadata and execution of bpel process .
    Cheers :)

  • Query regarding speech and telephony api

    hello everybody,
    i am thinking of doing my academic project in java. according to the project requirement i need to call a phone (pstn or mobile) from a pc and give a voice message to the receiver of the phone call. i thought of doing it with java speech api and telephony api. i would also like to know about javaphone api , java communications api and media framework. can the objective be achieved using the latter three? or do i have to go for speech and telephony api only. i am really confused. please guide me.
    where can i download jtapi library?
    also suggest some good tutorial for jsapi and jtapi.
    Thank you.
    Sriram K

    hi
    i'm also doing my project using jtapi.
    u can download JTAPI java files then compile it .u ll get the class file.if u know more about jtapi means mail [email protected]

Maybe you are looking for

  • Error while calling BAPI_PARTNEREMPLOYEE_CREATE

    Hi All, I am trying to call BAPI_PARTNEREMPLOYEE_CREATE BAPI in my java application using JCO But internally this BAPI calls VAP1 screen so currently i am getting error while calling this BAPI. please suggest to overcome this error Thanks in advance,

  • Get Thread information in a Servlet

    Hi, I'm wondering if there is a way to get the running thread information in a Servlet, Something like an ID. For example, each time the Servlet receives a new request, the Servlet container will create a new thread to run the code, I want to know an

  • Change Flash IDE default player in OSX?

    Does anyone know if it's possible to change the flash player that Flash IDE uses? As far as I know, it uses the special debugging version of the player. For some reason this player runs much slower than the regular standalone player in OSX. So I'm tr

  • "Cannot read the contents"

    I plugged my 80 GB iPod into my friend's computer to charge it, but I didn't realize he had iTunes version 4-point-something. When I unplugged it it couldn't find any music or videos that I had on before. Plugging it into my computer I got the error

  • ITunes 8.1.1 installs, but doesn't pull up.

    Every time I try to launch iTunes from my desktop, it says its only valid for products that are installed. And when I try to pull it up from the start menu, it makes another icon on my desktop that won't work. HELP!