Search in sources :

Example 21 with Message

use of com.jme3.network.Message in project jmonkeyengine by jMonkeyEngine.

the class AppletHarness method createCanvas.

private void createCanvas() {
    AppSettings settings = new AppSettings(true);
    // load app cfg
    if (appCfg != null) {
        InputStream in = null;
        try {
            in = appCfg.openStream();
            settings.load(in);
            in.close();
        } catch (IOException ex) {
            // Called before application has been created ....
            // Display error message through AWT
            JOptionPane.showMessageDialog(this, "An error has occured while " + "loading applet configuration" + ex.getMessage(), "jME3 Applet", JOptionPane.ERROR_MESSAGE);
            ex.printStackTrace();
        } finally {
            if (in != null)
                try {
                    in.close();
                } catch (IOException ex) {
                }
        }
    }
    if (assetCfg != null) {
        settings.putString("AssetConfigURL", assetCfg.toString());
    }
    settings.setWidth(getWidth());
    settings.setHeight(getHeight());
    JmeSystem.setLowPermissions(true);
    try {
        Class<? extends LegacyApplication> clazz = (Class<? extends LegacyApplication>) Class.forName(appClass);
        app = clazz.newInstance();
    } catch (ClassNotFoundException ex) {
        ex.printStackTrace();
    } catch (InstantiationException ex) {
        ex.printStackTrace();
    } catch (IllegalAccessException ex) {
        ex.printStackTrace();
    }
    appToApplet.put(app, this);
    app.setSettings(settings);
    app.createCanvas();
    context = (JmeCanvasContext) app.getContext();
    canvas = context.getCanvas();
    canvas.setSize(getWidth(), getHeight());
    add(canvas);
    app.startCanvas();
}
Also used : AppSettings(com.jme3.system.AppSettings) InputStream(java.io.InputStream) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)6 Message (com.jme3.network.Message)5 ClientRegistrationMessage (com.jme3.network.message.ClientRegistrationMessage)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 ByteBuffer (java.nio.ByteBuffer)4 GhostControl (com.jme3.bullet.control.GhostControl)2 Server (com.jme3.network.Server)2 Endpoint (com.jme3.network.kernel.Endpoint)2 ChannelInfoMessage (com.jme3.network.message.ChannelInfoMessage)2 GZIPCompressedMessage (com.jme3.network.message.GZIPCompressedMessage)2 ZIPCompressedMessage (com.jme3.network.message.ZIPCompressedMessage)2 RpcCallMessage (com.jme3.network.service.rpc.msg.RpcCallMessage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 BulletAppState (com.jme3.bullet.BulletAppState)1 BoxCollisionShape (com.jme3.bullet.collision.shapes.BoxCollisionShape)1 CompoundCollisionShape (com.jme3.bullet.collision.shapes.CompoundCollisionShape)1 SphereCollisionShape (com.jme3.bullet.collision.shapes.SphereCollisionShape)1 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)1 BitmapText (com.jme3.font.BitmapText)1 KeyTrigger (com.jme3.input.controls.KeyTrigger)1