home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 14 / IOPROG_14.ISO / soft / sdkjava / sdkjava.exe / SDKJava.cab / Samples / DirectX3 / dPlay / PlayDlg.java < prev    next >
Encoding:
Java Source  |  1998-03-05  |  2.6 KB  |  126 lines

  1. // 
  2. //  Copyright (C) 1998 Microsoft Corporation. All Rights Reserved.
  3. // 
  4. //  File:            PlayDlg.java
  5. //  Description:                Panel for user id entry
  6. //
  7.  
  8. import com.ms.com.*;
  9. import com.ms.directX.*;
  10. import com.ms.ui.resource.*;
  11. import com.ms.ui.*;
  12. import java.awt.*;
  13.  
  14.  
  15. class PlayDlg extends Panel implements DirectXConstants {
  16.     
  17.     Label            m_MemberLabel;
  18.     Label            m_SessionLabel;
  19.     TextField        m_MemberName;
  20.     TextField        m_SessionName;
  21.     Button            m_OKButton;    
  22.     DpChat            m_ChatInfo;
  23.  
  24.     public boolean    done=false;
  25.  
  26.     //=-----------------------------
  27.     // PlayDlg
  28.     //=-----------------------------        
  29.     PlayDlg(DpChat chatinfo){
  30.         m_ChatInfo=chatinfo;
  31.         initUI();
  32.     }
  33.     
  34.     //=-----------------------------
  35.     // cleanup
  36.     //=-----------------------------        
  37.     void cleanup(){
  38.         m_ChatInfo=null;
  39.         System.gc();
  40.     }
  41.  
  42.     //=-----------------------------
  43.     // DoWait
  44.     //=-----------------------------        
  45.     synchronized int DoWait(){
  46.         try {
  47.             this.wait();
  48.         }
  49.         catch (InterruptedException e){
  50.             return -1;
  51.         }
  52.         return 0;
  53.     }
  54.  
  55.     //=-----------------------------
  56.     // EndWait
  57.     //=-----------------------------        
  58.     synchronized void EndWait(){
  59.         this.notify();
  60.     }
  61.  
  62.  
  63.     //=-----------------------------
  64.     // initUI
  65.     //=-----------------------------        
  66.     void initUI(){
  67.         
  68.         setLayout(null);
  69.         
  70.         m_MemberLabel = new Label("Your Name");
  71.         m_MemberName= new TextField();
  72.         m_SessionLabel = new Label("Session Name");
  73.         m_SessionName= new TextField();
  74.         m_OKButton = new Button("Next");
  75.  
  76.         add (m_MemberLabel);
  77.         add (m_MemberName);
  78.         add (m_SessionLabel);
  79.         add (m_SessionName);
  80.         add (m_OKButton);
  81.  
  82.         
  83.         m_MemberLabel.setBounds(20,0,110,20);
  84.         m_MemberName.setBounds(140,0,160,20);
  85.  
  86.         m_SessionLabel.setBounds(20,30,110,20);
  87.         m_SessionName.setBounds(140,30,160,20);
  88.         
  89.         m_OKButton.setBounds(420,40,50,30);    
  90.  
  91.         if (m_ChatInfo.m_SessionName!=null){
  92.             m_SessionName.setText(m_ChatInfo.m_SessionName);
  93.             m_SessionName.setEnabled(false);
  94.         }
  95.  
  96.         if (m_ChatInfo.m_SessionName!=null)
  97.             m_SessionName.setText(m_ChatInfo.m_SessionName);        
  98.  
  99.     }
  100.  
  101.  
  102.     
  103.     //=-----------------------------
  104.     // handleEvent
  105.     //=-----------------------------        
  106.     public boolean handleEvent(Event evt){
  107.         if (evt.id==Event.ACTION_EVENT){
  108.             if (evt.target==m_OKButton){
  109.                 
  110.                 //Save off info..
  111.                 m_ChatInfo.m_SessionName= m_SessionName.getText();
  112.                 m_ChatInfo.m_UserShortName = m_MemberName.getText();
  113.                 m_ChatInfo.m_UserLongName  = m_MemberName.getText();
  114.                 
  115.                 //we are done!
  116.                 done=true;
  117.                 EndWait();                
  118.                 return true;
  119.             }
  120.         }
  121.         return super.handleEvent(evt);
  122.     }
  123.  
  124.     
  125. }
  126.