~ubuntu-branches/ubuntu/raring/libjboss-remoting-java/raring

« back to all changes in this revision

Viewing changes to src/main/org/jboss/remoting/samples/chat/client/Chat.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.jboss.remoting.samples.chat.client;
 
2
 
 
3
import java.awt.Dimension;
 
4
import java.awt.Toolkit;
 
5
 
 
6
import javax.swing.UIManager;
 
7
 
 
8
import org.jboss.remoting.samples.chat.utility.Debug;
 
9
import org.jboss.remoting.samples.chat.utility.Parameters;
 
10
 
 
11
/**
 
12
 * <p>Title: Chat</p>
 
13
 * <p>Description: </p>
 
14
 * <p>Copyright: Copyright (c) 2003</p>
 
15
 * <p>Company: </p>
 
16
 * @author Ron Sigal
 
17
 * @version 1.0
 
18
 */
 
19
 
 
20
public class Chat extends CloseableFrame {
 
21
  boolean packFrame = false;
 
22
 
 
23
  //Construct the application
 
24
  public Chat(String[] args)
 
25
  {
 
26
        for (int i=0; i< args.length; i++)
 
27
        {
 
28
                System.out.println(args[i]);
 
29
        }
 
30
    Parameters.initParameters(args);
 
31
 
 
32
    String debug = Parameters.getParameter("debug");
 
33
    if (debug != null && debug.charAt(0) == 'y')
 
34
    {
 
35
      Debug.turnOn();
 
36
//      xmlrmi.utility.Debug.turnOn();
 
37
    }
 
38
 
 
39
    RemoteStrategy remoteStrategy = null;
 
40
    ChatFrame frame = null;
 
41
 
 
42
    String remoteStrategyName = remoteStrategyName = Parameters.getParameter("remoteStrategy");
 
43
    if (remoteStrategyName == null)
 
44
        remoteStrategyName = "chat.client.RemoteStrategyXmlRmi_Impl";
 
45
 
 
46
    try
 
47
    {
 
48
      remoteStrategy = (RemoteStrategy) Class.forName(remoteStrategyName).newInstance();
 
49
      System.out.println("chat: created remote strategy: " + remoteStrategyName);
 
50
    } catch (Exception e)
 
51
    {
 
52
      System.out.println("chat: unable to create RemoteStrategyImpl: " + remoteStrategyName);
 
53
      System.out.println(e.toString());
 
54
      System.exit(-1);
 
55
    }
 
56
 
 
57
      LocalStrategy localStrategy = new LocalStrategy(this, remoteStrategy);
 
58
      frame = new ChatFrame(localStrategy);
 
59
      frame.show();
 
60
 
 
61
    //Validate frames that have preset sizes
 
62
    //Pack frames that have useful preferred size info, e.g. from their layout
 
63
    if (packFrame) {
 
64
      frame.pack();
 
65
    }
 
66
    else {
 
67
      frame.validate();
 
68
    }
 
69
    //Center the window
 
70
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
 
71
    Dimension frameSize = frame.getSize();
 
72
    if (frameSize.height > screenSize.height) {
 
73
      frameSize.height = screenSize.height;
 
74
    }
 
75
    if (frameSize.width > screenSize.width) {
 
76
      frameSize.width = screenSize.width;
 
77
    }
 
78
    frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
 
79
    frame.setVisible(true);
 
80
  }
 
81
 
 
82
  //Main method
 
83
  public static void main(String[] args) {
 
84
    try {
 
85
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 
86
    }
 
87
    catch(Exception e) {
 
88
      e.printStackTrace();
 
89
    }
 
90
    new Chat(args);
 
91
  }
 
92
}
 
 
b'\\ No newline at end of file'