codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  how to modify the JFrame to JApplet ( THANK)  almond at 08:29 on Monday, March 13, 2006
 

import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.PortableServer.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;



public class CamController extends JFrame
{
public JPanel videoViewer;

public static String hostName = ""; // This computer's host name
public static org.omg.CORBA.ORB orb;
public static rowc.MediaStore mediaStore;
public static rowc.Registration regObject;
public static NamingContext nc;

public static boolean connectedToServer = false; // Keep track of whether binded to Server

private final String PROPERTY_FILE = "project.conf";


public CamController(String args[])
{
System.out.println("initializing...");

initCorba(args);

// Determine this computer's ip address
try
{
java.net.InetAddress ia = java.net.InetAddress.getLocalHost();
hostName = ia.getHostName();
System.out.println("InetAddress = "+ia);
}
catch (java.net.UnknownHostException ex)
{
ex.printStackTrace();
}

// Call constructor AFTER getting ORB up because of ORB-dependent methods in VideoViewer
videoViewer = new VideoViewer();

JPanel contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(new BorderLayout());
this.setSize(new Dimension(580, 580));
this.setTitle("Cam Controller");

contentPane.add(videoViewer, BorderLayout.CENTER);

show();
}

private void initCorba(String commandLineArgs[])
{
System.out.println("Initializing CORBA... ");

try
{
// Initialize the ORB
java.util.Properties props = System.getProperties();

try
{
// Read properties from project property file that indicates location
// of Name and Event Services.

FileInputStream f = new FileInputStream(PROPERTY_FILE);
props.load(f);
f.close();
}
catch (FileNotFoundException e)
{
// Got this most likely because app is being ran in Java Web Start.
// Need to load property file differently.

ClassLoader cl = this.getClass().getClassLoader();
java.net.URL url = cl.getResource(PROPERTY_FILE);
props.load(url.openStream());
}

props.setProperty("org.omg.CORBA.ORBClass", "com.ooc.CORBA.ORB");
props.setProperty("org.omg.CORBA.ORBSingletonClass",
"com.ooc.CORBA.ORBSingleton");

orb = org.omg.CORBA.ORB.init(commandLineArgs, props);
}
catch (Exception e)
{
e.printStackTrace();
return;
}

try
{
// Find MediaStore using Naming Service
nc = NamingContextHelper.narrow(
orb.resolve_initial_references("NameService"));

// Resolve names with the Naming Service
NameComponent[] ncArray = new NameComponent[1];
ncArray[0] = new NameComponent("MediaStore","");
mediaStore = rowc.MediaStoreHelper.narrow(nc.resolve(ncArray));

ncArray[0] = new NameComponent("Registration","");
regObject = rowc.RegistrationHelper.narrow(nc.resolve(ncArray));

POA rootPOA =
POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

// Create policies for our persistent POA and activate

org.omg.CORBA.Policy[] policies = {
rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT),
rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID)
};

POA myPOA = rootPOA.create_POA("blahh",
rootPOA.the_POAManager(), policies);

myPOA.the_POAManager().activate();

connectedToServer = true;
}
catch (org.omg.CORBA.TRANSIENT e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(null,
"Unable to locate Naming Service.\nMake sure Naming Service is running.",
"Cam Viewer Error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
catch (Exception e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(null,
"Error locating remote objects.\nMake sure the CORBA server is running.",
"Cam Viewer Error", JOptionPane.ERROR_MESSAGE);
}

}


public static void main(String args[])
{
final CamController app = new CamController(args);
app.addWindowListener(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.out.println("About to stopCamViewer");
try
{
VideoViewer.terminate();
VideoViewer.stopCamViewer();
}
catch (Exception ex)
{
ex.printStackTrace();
}
System.exit(0);
}
}
);
}
}








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  2011 autumn and winter TOUGH Jeansmith new leather ( Figure )Moncler Quincy
•  Re: form2cgi list order
•  pls help me check this website http://www.buyluxuryclothing.com is real or fake?
•  Re: using html buttons to run vb script
•  Re: drop-down menu selected value
•  Re: Write text strings to Serial Port
•  Re: Submit button, email setup
•  Re: TO SEND Text message or URL through Clickatell
•  sending of file over network


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2011