From d9822dd92e9827e87ce8a61237867aad57cfc868 Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Wed, 23 Mar 2011 00:16:11 +0000 Subject: [PATCH] * Created test for (non-existent) safe canvas git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7076 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../src/test/jme3test/awt/TestSafeCanvas.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 engine/src/test/jme3test/awt/TestSafeCanvas.java diff --git a/engine/src/test/jme3test/awt/TestSafeCanvas.java b/engine/src/test/jme3test/awt/TestSafeCanvas.java new file mode 100644 index 000000000..378d38afe --- /dev/null +++ b/engine/src/test/jme3test/awt/TestSafeCanvas.java @@ -0,0 +1,56 @@ +package jme3test.awt; + +import com.jme3.app.SimpleApplication; +import com.jme3.material.Material; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.shape.Box; +import com.jme3.system.AppSettings; +import com.jme3.system.JmeCanvasContext; +import java.awt.Canvas; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JFrame; + +public class TestSafeCanvas extends SimpleApplication { + + public static void main(String[] args){ + AppSettings settings = new AppSettings(true); + settings.setWidth(640); + settings.setHeight(480); + + final TestSafeCanvas app = new TestSafeCanvas(); + app.setPauseOnLostFocus(false); + app.setSettings(settings); + app.createCanvas(); + + JmeCanvasContext context = (JmeCanvasContext) app.getContext(); + Canvas canvas = context.getCanvas(); + canvas.setSize(settings.getWidth(), settings.getHeight()); + + JFrame frame = new JFrame("Test"); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + app.stop(); + } + }); + frame.getContentPane().add(canvas); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + @Override + public void simpleInitApp() { + flyCam.setDragToRotate(true); + + Box b = new Box(Vector3f.ZERO, 1, 1, 1); + Geometry geom = new Geometry("Box", b); + Material mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md"); + mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); + geom.setMaterial(mat); + rootNode.attachChild(geom); + } +}