Need to get Object key

Hi All,
In transaction 'APPCREATE' im going to create appraisal process. Once i created the appraisal, then 'Appraisal ID' will be generated. Now I need to get the generated appraisal ID.
Can i use change document header table for that? I have no idea about that.
Any ideas will be highly appreciated.
Thanks.

Any suggestions?

Similar Messages

  • How to get object key before load data into form?

    I need to get object key (e.g. ItemCode in Item Master Data From ,docEntry in A/R Invoice From) to calculate and do something  before data is loaded into this form .
    I try to use SAPbouiCOM.BusinessObjectInfo.objectKey as in this code.
    Private Sub oApp_FormDataEvent(ByRef pVal As SAPbouiCOM.BusinessObjectInfo, ByRef BubbleEvent As Boolean) Handles oApp.FormDataEvent
           If pVal.FormTypeEx = "672" And pVal.BeforeAction = True And pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD Then
                   oApp.MessageBox(pVal.ObjectKey)
           End If
    End Sub
    But this fields doesn't valid under this condition (form DI help file).
    - The property returns an empty value in the before notification of the Load action (et_FORM_DATA_LOAD) triggered by a Find operation.
    How can I get this value(key)?

    Janos
    I can't do a calculation after data is loaded because what I'm going to do is that if the opening entry match my condition , the system will not let that user see that entry (bubbleEvent = False).
    I think when formDataEvent is triggered B1 know which entry are going to load because before this event is triggered we did one of following ways
    1. choose from "choose from list windows"
    2. enter docEntry or itemCode or cardCode  and then press Find Button
    3. press "next/previous record button"
    4. press linked button (orange arrow)
    Choice 3 and 4 can be done by retrieve data from BusinessObjectInfo.objectKey (I've tested and it return entry key that is going to open correctly).
    but 1 and 2 can't (it return empty as I mention before).
    thanks
    Edited by: daron tancharoen on Aug 5, 2008 2:34 PM

  • Need to get primary key value from entity

    Hi,
    I have 2 pages. In the first page on click of GO button, Im inserting data into table using EO and Immediately navigating to second page.
    Primary Key value is generated in EOImpl java file.
    In second screen, in the header region, I need to show the row inserted in table.
    to query the VO, i need to have primary key generated in EOImpl.
    Please let me know how can i get this value in either in PFR of first page or in PR of second page. Thanks.

    Hi
    have you included the eo that tyou are refering to in the header oif the second page..
    if both pages are using the same AM, the data will appear.
    at worse can you can get the ID from the eo using amethod in your AM.

  • How to get Object key name

    var obj:Object = {a:"foo", b:"bar"}
    obj.a // foo keya=a value='foo'
    obj.b // bar keya=b value="bar"
    for each (var value:Object in obj){
    trace(value);
    Q: How can I get key from obj liking hash?

    var obj:Object = {a:"foo", b:"bar"}
    var retValue:String;
    for ( var key:* in obj)
    if ( obj[key] == "foo")
    retValue= key;
    break;
    return retValue;
    (you could of course return it straight from within the loop
    but thats not very good idea, so , you get the idea right?

  • How to get the key values of record in ADF Read-only Form?

    Hi
    I am using ADF Business Component VO.
    I have a search page( ADF Search Form) and I am displaying the results of the search in a ADF Read-Only Table( only few columns are shown) .Then by selecting a record and clicking on the button 'View' , I am navigating to a different page(ADF Read-Only Form) to show all the columns of the table for the selected record.
    In the second page, I have one more button 'view child details'.Now when I click on this view child details button, I have to show another page(ADF Read-Only Form) which fetches the data from one of the child tables of parent record.
    My idea is to create a ViewLink between the parent and child tables.( I have more than 15 child tables for a parent table).
    Is there anyother way to achieve this functionality?
    Please respond ASAP.
    Thanks in advance.
    ~Sivaji..
    Message was edited by:
    Sivaji...the boss

    Sijav,
    ASAP?
    Anyway - yes, you can do this with a view link. When you add the child table to the application model, make sure you actually add it as a child of the parent table instance (select the parent VO first, then use the shuttle to add it). This way, the parent->child relationship should be coordinated for you automatically. You should not need to get the key values manually.
    Then, when you create the page to show the detail table, make sure you use the child table that is shown as a child of the parent table in the data control palette (expand parent table to see the child).
    Hope this helps,
    John

  • Object Key required for document in Script

    Hi All,
    I require Object Key for Document to compair with Nast-vstat. Requirement is check vstat value. How will i get object key in SAP Script.
    Regards
    Divekar Mahadev

    Objectkey(objky) you can get from NAST table. It is basically the document number.
    Regards,
    Mallick

  • Getting which key is pressed without adding keylistener

    I need to get which key is being currently pressed in valuechanged of treeselection event. i need to know which key is pressed before executing the code for treeselection event

    1. In the future, note there is a Swing forum exactly for questions like this, questions about Swing:
    http://forum.java.sun.com/forum.jspa?forumID=57
    2. Can you explain your problem better?
    Demo:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class KeyEventExample implements Runnable, KeyListener, TreeSelectionListener {
        @Override public void run() {
            JTree tree = new JTree();
            tree.addKeyListener(this);
            tree.addTreeSelectionListener(this);
            JFrame f = new JFrame("KeyEventExample");
            f.getContentPane().add(new JScrollPane(tree));
            f.pack();
            f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        @Override public void keyPressed(KeyEvent evt) {
            System.out.println("keyPressed " + evt.getKeyCode());
        @Override public void keyReleased(KeyEvent evt) {
            System.out.println("keyReleased " + evt.getKeyCode());
        @Override public void keyTyped(KeyEvent evt) {
            System.out.println("keyTyped " + evt.getKeyChar());
        @Override public void valueChanged(TreeSelectionEvent evt) {
            System.out.println("valueChanged " + evt.getPath());
        public static void main(String[] args) {
            EventQueue.invokeLater(new KeyEventExample());
    }

  • To get the Workflow status using the Object Key

    Hi Experts,
    Do we have any transaction code or a Standard table where I can see the status of the Workflow using the Object Key.
    For example I have an Invoice Document number for which a Workflow has been triggered and now I want to see the which workflow has been triggered and what is the status for the same. I have only the Invoice Document Number.
    I think I can use the SWI1, SWEL etc but I don't have Object key as Input field.
    Thanks in advance.
    Regards,
    SRinivas

    Hi,
    You can find the workitem id in table SWW_WI2OBJ.
    Here you need to pass the invoice number in "Instacne ID" with leading zeros, business object in Object type.
    This may take little bit longer time.
    After getting the workitem number then look into table SWWWIHEAD for the workitem status.
    Thanks and regards,
    SNJY

  • I need to get the cluster information using"MSCluster.Cluster" object

    Hi,
    Please anyone solve my problem ? I need to get the cluster information using"MSCluster.Cluster" object.
    Set objCluster = CreateObject("MSCluster.Cluster")
    objCluster .open <clustername>
    If i run the vbscript " Microsoft VBScript runtime error: ActiveX component can't create object: 'MSCluster.Cluster' " error is thrown.
    Kindly explain what is the issue and what can i do ? 
    -Sundar.

    this question was closed and answered a long time ago.
    Post questions about WS2012 in th WS2012 forum.
    The cluster object will no longer work in WS2012.  Use the supplied CmdLets and utilities.
    post future questions in the WS2012 forum.
    ¯\_(ツ)_/¯

  • Need to get IRole object using Roles Display Name

    Hi,
    I need to get IRole object using Roles Display Name. I had the below code in EP 2004 SP12 and it works. But the same code dont work in EP 2004s SP13
    user = request.getUser();
    profile = request.getComponentContext().getProfile();     
    String strRoles = profile.getProperty("Roles");
    String strRole[] = strRoles.split(",");
    IRoleFactory roleFactory = UMFactory.getRoleFactory();
    String roleUniqueId = null;
    int i = 0;
    boolean flagRedirect = false;
    for(i = 0; i < strRole.length; i++){
         try
              com.sap.security.api.IRole role = roleFactory.getRoleByUniqueName(strRole<i>);
              roleUniqueId = role.getUniqueID();
              if(!user.isMemberOfRole(roleUniqueId, true))
                   continue;
              flagRedirect = true;                    
              break;
         catch(UMException ex)
         catch(IOException ex)
    if(!flagRedirect){
    Where property Roles will have comma separated roles display names like "com.ABC.ortho_reports,com.ABC.lawns_ortho_reports,com.ABC.executive_reports"
    Please advise.

    Thanks Mrudula for the response. Sorry for the delay in responding.
    I get UMEException with the message "Role with uniqueName com.ABC.general not found"
    But it works fine if i specify Role unique role (like pcd:portal_content/com.abc.Marketing_Workbench/com.abc.Roles/com.abc.general).
    We are in the process of upgrading Portal environment from EP6.0 SP12 to EP7.0 SP13. Above scenario works fine in the older environment.

  • Is it possible to get object type name  with help of key field?

    can any one tell me is it really possible to get the object type name if i have only key field,
    are there any tables which store the object type names & keyfield.  or there are any functionmodue which gives object type name by entering keyfield.

    Hello,
    If the PO has workflows associated with it, there is a table SWIWIOBJCT which stores details of the workitem, object key , object type details.
    If you input the object key to this table ( For ex: PO number in this case) , it will give you the corresponding object type for the object key for Workitem type F.
    Thanks,
    Sowmya Arni

  • How to get object type and object key of bapi_acc_gl_posting_post

    Hi,
       I want to upload data from flat file to FB01 transaction using BAPI. For this i found bapi_acc_gl_posting_post. How should i get the obj type and object key for this bapi.
    Please let me know wether this is correct bapi for fb01 transaction.
    Thanks in advance,
    Regards,
    Sun.

    Hi,
       I want to upload data from flat file to FB01 transaction using BAPI. For this i found bapi_acc_gl_posting_post. How should i get the obj type and object key for this bapi.
    Please let me know wether this is correct bapi for fb01 transaction.
    Thanks in advance,
    Regards,
    Sun.

  • How to get object type and object key from Bapi_acc_gl_posting_post

    Hi,
      Currently iam implementing FB01 transaction thru Bapi_acc_gl_posting_post.
    I got object key by including document no, fiscal year and Document data
    I got object type from TTYP table. But iam not sure it is correct.
    After implemeting the BAPI return code is giving successfull and i commited the process.
    But at last data is not updating in BKPF table. There is no document number displayed at BKPF...Please go thru and do the needful its urgent.
    Thanks in advance....
    Regards,
    Ganga

    Hi Max,
            I have executed it and it is working only for GL posting but i need to make this for different accounting types like vendors, customers, material customers etc.
    I found BAPI_ACC_DOCUMENT_POST. when i executed it is giving error as 'Line entered several Times'.
    I following is my code. If time permits please go thru my code and do the need ful..
    Thanks in advance.
    REPORT  zk_fi_fb01                     .
    Data: v_objkey(20) type c.
    Data: Docheader type BAPIACHE09.
    Data: ACCOUNTGL LIKE BAPIACGL09 occurs 0 with header line,
         ACCOUNTRECEIVABLE like BAPIACAR09,
          ACCOUNTPAYABLE like BAPIACAP09 occurs 0 with header line,
          CURRENCYAMOUNT like BAPIACCR09 occurs 0 with header line,
          RETURN like BAPIRET2 occurs 0.
    Data: obj_typ like BAPIACHE09-OBJ_TYPE,
          OBJ_KEY like BAPIACHE09-OBJ_KEY,
          OBJ_SYS like BAPIACHE09-OBJ_SYS.
    *Data: gv_belnr type belnr_d.
    *Data:file_Na type String.
    Data: lsys like TBDLS-LOGSYS.
    *START OF SELECTION
    START-OF-SELECTION.
    *CALL FUNCTION 'NUMBER_GET_NEXT'
    EXPORTING
       nr_range_nr                  = '19'
       object                       = 'RF_BELEG' "'FIAA-BELNR'
      QUANTITY                      = '1'
      SUBOBJECT                     = '7777'
      TOYEAR                        = '2007'
      IGNORE_BUFFER                = ' '
    IMPORTING
      NUMBER                        = gv_belnr
    QUANTITY                      =
    RETURNCODE                    =
    *CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
    IMPORTING
      OWN_LOGICAL_SYSTEM                   = lsys
    EXCEPTIONS
      OWN_LOGICAL_SYSTEM_NOT_DEFINED       = 1
      OTHERS                               = 2
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    *concatenate gv_belnr '7777' '2007' into v_objkey.
    *Filling Document Header Details
    *Docheader-OBJ_TYPE = 'BEBD'.
    *Docheader-OBJ_key = V_objkey.
    *Docheader-OBJ_SYS = lsys.
    docheader-BUS_ACT = 'RFBU'.
    Docheader-USERNAME = sy-uname.
    Docheader-COMP_CODE = '7777'.
    Docheader-DOC_DATE   = '20070724'.
    Docheader-PSTNG_DATE = '20070725'.
    Docheader-FISC_YEAR = '2007'.
    Docheader-DOC_TYPE = 'KZ'.
    *Item data for ACCOUNTGL
    ACCOUNTGL-ITEMNO_ACC = '0000000001'.
    ACCOUNTGL-GL_ACCOUNT = '0000000501'.
    ACCOUNTGL-DOC_TYPE   =  'KZ'.
    ACCOUNTGL-COMP_CODE  = '7777'.
    ACCOUNTGL-FISC_YEAR  = '2007'.
    ACCOUNTGL-PSTNG_DATE = '20070725'.
    *ACCOUNTGL-DE_CRE_IND = 'S'.
    append ACCOUNTGL.
    ACCOUNTGL-ITEMNO_ACC = '0000000002'.
    ACCOUNTGL-GL_ACCOUNT = '0000400002'.
    ACCOUNTGL-DOC_TYPE   = 'KR'.
    ACCOUNTGL-COMP_CODE  = '7777'.
    ACCOUNTGL-FISC_YEAR  = '2007'.
    ACCOUNTGL-PSTNG_DATE = '20070725'.
    *ACCOUNTGL-DE_CRE_IND = 'H'.
    append ACCOUNTGL.
    *Account payable
    ACCOUNTPAYABLE-ITEMNO_ACC = '0000000001'.
    ACCOUNTPAYABLE-GL_ACCOUNT = '0000000102'.
    ACCOUNTPAYABLE-COMP_CODE  = '7777'.
    append ACCOUNTPAYABLE.
    ACCOUNTPAYABLE-ITEMNO_ACC = '0000000002'.
    ACCOUNTPAYABLE-GL_ACCOUNT = '0000400002'.
    ACCOUNTPAYABLE-COMP_CODE  = '7777'.
    append ACCOUNTPAYABLE.
    *Currency Amount
    CURRENCYAMOUNT-ITEMNO_ACC = '0000000001'.
    CURRENCYAMOUNT-CURRENCY_ISO = 'INR'.
    MOVE 1000 TO CURRENCYAMOUNT-AMT_DOCCUR.
    Append CURRENCYAMOUNT.
    CURRENCYAMOUNT-ITEMNO_ACC = '0000000002'.
    CURRENCYAMOUNT-CURRENCY_ISO = 'INR'.
    MOVE '1000-' to CURRENCYAMOUNT-AMT_DOCCUR.
    Append CURRENCYAMOUNT.
    clear CURRENCYAMOUNT.
    clear ACCOUNTGL.
    clear ACCOUNTPAYABLE.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader          = Docheader
      CUSTOMERCPD             =
      CONTRACTHEADER          =
    IMPORTING
       OBJ_TYPE                =  obj_typ
       OBJ_KEY                 =  obj_key
       OBJ_SYS                 =  obj_sys
      tables
       ACCOUNTGL               = ACCOUNTGL[]
      ACCOUNTRECEIVABLE       =
       ACCOUNTPAYABLE          = ACCOUNTPAYABLE
      ACCOUNTTAX              =
        currencyamount          = CURRENCYAMOUNT
      CRITERIA                =
      VALUEFIELD              =
      EXTENSION1              =
        return                  = return.
    if sy-subrc = 0.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
       WAIT          = ' '.
    endif.
    if sy-subrc = 0.
    WRITE: / OBJ_KEY,
             OBJ_TYP,
             OBJ_SYS.

  • Need to click to get a key listener

    Hi. I need to click in some part of the explorer window to make the movie "listen" my keyboard, and i strongly need to get rid of this click, otherwise it doesn't listen the key and stays freeze.
    This looks like the old "click to activate", in fact it works exactly like that, but i'd tried with opera, chrome, firefox a even IE and i can't solve this. Also i've tried some old post that use and noClickToActivate.js, but it doesn't work either.
    There is some configuration or file someone use and actually works?
    Thanks in advance!

    Mista, you are correct! thank you so very much!!!!
    how about creating pop up windows? I am talking aboutj
    voluntary pop ups. when you click on a link.
    go to
    http://virtualvisitor.com/portfolio.html
    and click on the motorcycle link, then click on one of the
    motorcycles on that page. this is my QTVR portfolio. when someone
    on a PC and using IE has to still click an Active X warning each
    and everytime one of my pop up windows comes up, which is so
    annoying that I think most will give up trying to see my Quicktime
    VR photography.

  • Getting objects to move between PCs

    After CS 150, I find myself back in the world of Java. I recently learned a neat language called Processing (a.k.a. Proce55ing), and I am one of the coders (and am way rusty to be of much use at this point) for a really cool project.
    I'm wondering if I can nag you with some questions on java.net.*. I need to get some objects passed around between 3 PCs. I need to know about latency issues. Basically, we've got Java doing OpenGL graphics on 6 projectors powered by 3 computers. Imagine each PC having a really wide screen... when a autonomous creature gets to the edge of one PC, it needs to continue its thang on the next PC... move fluidly.
    I've checked out some Java.net.* sample code on sun's site. Specifically their KnockKnock Server. However, its multithread support is for interacting with clients on a one-on-one basis... not like a chat-room style environment. So, I don't even have any sample code for a ultra-basic Java Chat Room.... nor do I know how to pass anything but a string to the server, or to the client.
    There are ways to use my limited knowledge to do what I want to do... just pass a string, and have the server store that into a variable which is accessible by every server thread. Then, create a loop in main that keeps searching through that array of strings to pass them off to the PC... the string would have the coordinate information of the autonomous creature, and create a new one of that object with those Vec3f point. However, latency is a key issue, and it would be easiest if I could just pass an object to the server (in this case: a SimpleVehicle) along with an intended target computer, and then that computer would get that vehicle to add to its array of SimpleVehicles. The important thing is speed, so it might be best to have every computer have a client<->server connection with each other... I get utterly baffled reading the Java Docs. But, I seem to understand code when I see it (I can only reverse engineer). I especially understand the KnockKnock Server and MultiClient code on the Sun's Java Networking Tutorial.
    Any pointers to which methods I need to learn (I already realize I'm going to need to downcast the SimpleVehicle object back into a SimpleVehicle after it gets sent). Thanks a million.

    Ok, try this.
    The simplistic application sends colored balls between instances of itself which can be on any machine on your network.
    As a ball reaches the left side of the window it is in, it gets sent to the machine on it's left (if any), likewise if it reaches the right side of the window it gets sent to the machine on it's right. If there is no machine on the side the ball is trying to go, it rebounds within the window it is in.
    So, a simple test is to run three instances on the same machine, one is regarded as one the left on as on the right and one as in the middle
    To start the one on the left:
    java Ziniman1 8000 -right localhost:8001
    To start the one in the middle:
    java Ziniman1 8001 -left localhost:8000 -right localhost:8002
    To start the one on the right:
    java Ziniman1 8002 -left localhost:8001
    Note: You need to start these pretty quickly one after the other or the socket creation will time out. I'll leave that to you to fix ;)
    Once the apps are running, move them so they are next to each other, left to right (the port numbers used as the server port are in the JFrame title).
    To get create a ball, just click on one of the white panels, use the radio buttons at the bottom to change size/color/direction of the new balls.
    Once you've got the hang of the thing, try moving some instances to other machnes.
    Enjoy!
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class Ziniman1
         static final String LEFT= "Left";
         static final String RIGHT= "Right";
         static class Ball
              implements Serializable
              public int x= -1;
              public int y;
              public int size= 10;
              private Color mColor;
              public Ball(Color color) { mColor= color; }
              public Ball(Color color, int y) { mColor= color; this.y= y; }
              public Color getColor() { return mColor; }
              public String toString() { return "(" +x +"," +y +") x " +size; }
         static interface DirectionalListener
              public void left(Ball ball);
              public void right(Ball ball);
         static class Directional
              private DirectionalListener mListener= null;
              public final void setListener(DirectionalListener listener) {
                   mListener= listener;
              protected final void fireLeft(Ball ball)
                   if (mListener != null)
                        mListener.left(ball);
              protected final void fireRight(Ball ball)
                   if (mListener != null)
                        mListener.right(ball);
         static class Server
              extends Directional
              public Server(final int port)
                   new Thread() {
                        public void run() {
                             try {
                                  ServerSocket listenSocket= new ServerSocket(port);
                                  System.err.println("Server listening on port " +port);
                                  while (true)
                                       connect(listenSocket.accept());
                             catch (Exception e) {
                                  e.printStackTrace();
                   }.start();
              private synchronized void connect(final Socket socket)
                   Thread thread= new Thread() {
                        public void run() {
                             try {
                                  ObjectInputStream is=
                                       new ObjectInputStream(socket.getInputStream());
                                  while (true) {
                                       String side= (String) is.readObject();
                                       Ball ball= (Ball) is.readObject();
                                       if (side.equals(RIGHT))
                                            fireLeft(ball);
                                       else
                                            fireRight(ball);
                             catch (Exception e) {
                                  e.printStackTrace();
                   thread.setDaemon(true);
                   thread.start();
         static class Client
              private ObjectOutputStream mOs;
              private String mSide;
              public Client(String host, int port, String side)
                   throws Exception
                   mSide= side;
                   Socket socket= new Socket(host, port);
                   mOs= new ObjectOutputStream(socket.getOutputStream());
                   System.err.println(
                        mSide +" client connected to " +host +":" +port);
              private void send(Ball ball)
                   try {
                        mOs.writeObject(mSide);
                        mOs.writeObject(ball);
                   catch (Exception e) {
                        e.printStackTrace();
         static abstract class BallPanel
              extends JPanel
              public void paint(Graphics g)
                   g.setColor(Color.WHITE);
                   g.fillRect(0, 0, getSize().width, getSize().height);
                   Iterator balls= getBalls();
                   while (balls.hasNext()) {
                        Ball ball= (Ball) balls.next();
                        g.setColor(ball.getColor());
                        g.fillOval(ball.x, ball.y, ball.size, ball.size);
              public Dimension getPreferredSize() {
                   return new Dimension(300, 240);
              public abstract Iterator getBalls();
         static class Gui
              extends Directional
              private Runnable mUpdater= new Runnable() {
                   public void run() { mBallPanel.repaint(); }
              private ArrayList mLeft= new ArrayList();
              private ArrayList mRight= new ArrayList();
              private ArrayList mBalls= new ArrayList();
              private BallPanel mBallPanel= new BallPanel() {
                   public Iterator getBalls() {
                        return mBalls.iterator();
              public Gui(String title)
                   final JRadioButton red= new JRadioButton("Red");
                   final JRadioButton green= new JRadioButton("Green");
                   final JRadioButton blue= new JRadioButton("Blue");
                   ButtonGroup group= new ButtonGroup();
                   group.add(red);
                   group.add(blue);
                   group.add(green);
                   final JRadioButton large= new JRadioButton("Large");
                   final JRadioButton small= new JRadioButton("Small");
                   group= new ButtonGroup();
                   group.add(large);
                   group.add(small);
                   final JRadioButton left= new JRadioButton("Left");
                   final JRadioButton right= new JRadioButton("Right");
                   group= new ButtonGroup();
                   group.add(left);
                   group.add(right);
                   red.setSelected(true);
                   small.setSelected(true);
                   right.setSelected(true);
                   mBallPanel.addMouseListener(new MouseAdapter() {
                        public void mousePressed(MouseEvent e) {
                             Ball ball= new Ball(
                                  red.isSelected() ? Color. RED :
                                  blue.isSelected() ? Color.BLUE : Color.GREEN);
                             ball.x= e.getX();
                             ball.y= e.getY();
                             ball.size= large.isSelected() ? 20 : 10;
                             if (left.isSelected())
                                  left(ball);
                             else
                                  right(ball);
                   JPanel panel= new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4));
                   panel.add(red);
                   panel.add(blue);
                   panel.add(green);
                   panel.add(large);
                   panel.add(small);
                   panel.add(left);
                   panel.add(right);
                   JFrame frame= new JFrame(title);
                   frame.getContentPane().add(mBallPanel, BorderLayout.CENTER);
                   frame.getContentPane().add(panel, BorderLayout.SOUTH);
                   frame.pack();
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame.setVisible(true);
              public synchronized void move(int delta)
                   Iterator left= mLeft.iterator();
                   while (left.hasNext()) {
                        Ball ball= (Ball) left.next();
                        ball.x -= delta;
                        if (ball.x <= 0) {
                             left.remove();
                             mBalls.remove(ball);
                             fireLeft(ball);
                   Iterator right= mRight.iterator();
                   while (right.hasNext()) {
                        Ball ball= (Ball) right.next();
                        ball.x += delta;
                        if (ball.x >= (mBallPanel.getSize().width -ball.size)) {
                             right.remove();
                             mBalls.remove(ball);
                             fireRight(ball);
                   SwingUtilities.invokeLater(mUpdater);
              public synchronized void left(Ball ball)
                   mLeft.add(ball);
                   mBalls.add(ball);
                   if (ball.x < 0)
                        ball.x= mBallPanel.getSize().width -(ball.size/2);
                   SwingUtilities.invokeLater(mUpdater);
              public synchronized void right(Ball ball)
                   mRight.add(ball);
                   mBalls.add(ball);
                   if (ball.x < 0)
                        ball.x= ball.size/2;
                   SwingUtilities.invokeLater(mUpdater);
         static class Controller
              public Controller(
                   final Gui gui, final Server server,
                   final Client left, final Client right)
                   gui.setListener(new DirectionalListener() {
                        // Ball reached the left
                        public void left(Ball ball)
                             ball.x= -1;
                             if (left == null)
                                  gui.right(ball);
                             else
                                  left.send(ball);
                        // Ball reached the right
                        public void right(Ball ball)
                             ball.x= -1;
                             if (right == null)
                                  gui.left(ball);
                             else
                                  right.send(ball);
                   server.setListener(new DirectionalListener() {
                        // Ball came from the left
                        public void left(Ball ball) {
                             gui.right(ball);
                        // Ball came from the right
                        public void right(Ball ball) {
                             gui.left(ball);
                   Thread thread= new Thread() {
                        public void run() {
                             while (true) {
                                  try { sleep(100); }
                                  catch (InterruptedException e) { }
                                  gui.move(10);
                   thread.setDaemon(true);
                   thread.start();
         private static final String USAGE=
              "Usage: java Ziniman1 " +
              "<server port> [-left <host:port>] [-right <host:port>]";
            public static void main(String[] argv)
              throws Exception
              if (argv.length < 1)
                   barf();
              int leftPort= -1;
              int rightPort= -1;
              String leftHost= "localhost";
              String rightHost= "localhost";
              int serverPort= Integer.parseInt(argv[0]);
              for (int i= 1; i< argv.length; i += 2) {
                   if (argv.equals("-left")) {
                        if (argv.length == i+1)
                             barf();
                        String url= argv[i+1];
                        if (url.indexOf(":") < 0)
                             barf();
                        leftHost= url.substring(0, url.indexOf(":"));
                        leftPort= Integer.parseInt(url.substring(url.indexOf(":")+1));
                   else if (argv[i].equals("-right")) {
                        if (argv.length == i+1)
                             barf();
                        String url= argv[i+1];
                        if (url.indexOf(":") < 0)
                             barf();
                        rightHost= url.substring(0, url.indexOf(":"));
                        rightPort= Integer.parseInt(url.substring(url.indexOf(":")+1));
              new Controller(
                   new Gui("Balls @ " +serverPort),
                   new Server(serverPort),
                   leftPort > 0 ? new Client(leftHost, leftPort, LEFT) : null,
                   rightPort > 0 ? new Client(rightHost, rightPort, RIGHT) : null);
         private static void barf()
              System.err.println(USAGE);
              System.exit(-1);

Maybe you are looking for