Package java.awt

Examples of java.awt.Canvas$AccessibleAWTCanvas


            }
        });
    }

    public ScreenTestPlayer() {
        canvas = new Canvas();
        canvas.setBackground(Color.black);
        canvas.setSize(550, 300);

        contentPane = new JPanel();
        contentPane.setBackground(Color.black);
View Full Code Here


    public SetAudioOutputTest(final String mrl) {
        factory = new MediaPlayerFactory();
        mediaPlayer = factory.newEmbeddedMediaPlayer();
        audioOutputs = factory.getAudioOutputs();

        canvas = new Canvas();
        canvas.setBackground(Color.black);

        controlsPanel = new JPanel();
        controlsPanel.setBorder(new EmptyBorder(8, 8, 8, 8));
        controlsPanel.setLayout(new BoxLayout(controlsPanel, BoxLayout.X_AXIS));
View Full Code Here

    private RasterFormatTag rasterFormatTag = null;

    private static final ImageLayout layoutHelper (ImageLayout layout,
                                                   Image image) {
        /* Determine image width and height using MediaTracker. */
        MediaTracker tracker = new MediaTracker(new Canvas());
        tracker.addImage(image, 0);
        try {
            tracker.waitForID(0);
        } catch (InterruptedException e) {
            e.printStackTrace();
View Full Code Here

      try {
         Game game = (Game) Class.forName(getParameter("game")).newInstance();
        
         container = new Container(game);
         canvas = new ContainerPanel(container);
         displayParent = new Canvas() {
            public final void addNotify() {
               super.addNotify();
               startLWJGL();
            }
            public final void removeNotify() {
View Full Code Here

     * Note: this disables focus traversal keys for the canvas it creates.
     */
    void attachViewCanvas(JPanel panel) {
        rb = ClientContextJME.getWorldManager().getRenderManager().createRenderBuffer(RenderBuffer.Target.ONSCREEN, width, height);
        ClientContextJME.getWorldManager().getRenderManager().addRenderBuffer(rb);
        final Canvas canvas = ((OnscreenRenderBuffer) rb).getCanvas();

        canvas.setVisible(true);
        canvas.setBounds(0, 0, width, height);

        // Fix bug 884
        canvas.setFocusTraversalKeysEnabled(false);

        panel.addComponentListener(new ComponentAdapter() {

            public void componentResized(final ComponentEvent e) {
                // workaround for race condition between EDT and MTGame renderer thread
                // when using JOGL 2.0. Need to stop MTGame renderer to update canvas
                ClientContextJME.getWorldManager().getRenderManager().setRunning(false);

                final int width = e.getComponent().getWidth();
                final int height = e.getComponent().getHeight();
                float aspectRatio = (float) width / (float) height;
                logger.fine("Resizing " + e);
                // ty to acquire synchronization semaphore
                try{
                    ClientContextJME.getWorldManager().getRenderManager().getSynchronizer().acquire();
                } catch(InterruptedException ex){
                    logger.severe("Interrupted while trying to acquire semaphore");
                    return;
                }
               
                getCanvas().setBounds(0, 0, width, height);
                ClientContextJME.getWorldManager().getRenderManager().getSynchronizer().release();
                cameraComponent.setViewport(width, height);
                cameraComponent.setAspectRatio(aspectRatio);
                viewProperties.setFieldOfView(viewProperties.getFieldOfView());
                // start MTGame renderer again
                ClientContextJME.getWorldManager().getRenderManager().setRunning(true);
            }

        });

        // Listen for (de)iconification of root window and start/stop the renderer accordingly
        Window w = SwingUtilities.getWindowAncestor(panel);
        if (w != null) {
            w.addWindowListener(new WindowAdapter() {               
                @Override
                public void windowDeiconified(WindowEvent e) {
                    // OWL issue #22 -- restore the default frame rate
                    int desiredFrameRate = JmeClientMain.getDesiredFrameRate();
                    ClientContextJME.getWorldManager().getRenderManager().setDesiredFrameRate(desiredFrameRate);
                }

                @Override
                public void windowIconified(WindowEvent e) {
                    // OWL issue #22 -- instead of stopping the renderer, set
                    // the framerate down to 1 fps. This will still allow the
                    // system to make progress on tasks that require the
                    // renderer to update, but should cut CPU usage way down.
                    ClientContextJME.getWorldManager().getRenderManager().setDesiredFrameRate(1);
                }
            });
        }

        final Semaphore waitForReady = new Semaphore(0);

        // Wait for the renderer to become ready
        rb.setBufferUpdater(new BufferUpdater() {

            public void init(RenderBuffer arg0) {
                logger.info("RENDERER IS READY !");
                waitForReady.release();

                // OWL issue #14: ignore repaints after the first to avoid
                // flickering on Windows. The first paint is necessary to
                // setup the canvas.  Once we get to this point, the canvas
                // is initialized, and we can ignore further repaints.
                canvas.setIgnoreRepaint(true);
            }
        });

        // issue 999: don't add the canvas until after the BufferUpdater is
        // registered, to make sure we don't miss the initialization call.  Also
        // force a repaint to be sure the initialization call happens eventually,
        // even on headless clients
        panel.add(canvas, BorderLayout.CENTER);
        canvas.repaint();

        try {
            waitForReady.acquire();
        } catch (InterruptedException ex) {
            Logger.getLogger(ViewManager.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

     * Make sure that the Wonderland client main (3D) window has key focus.
     */
    public static void ensureKeyFocusInMainWindow() {
        SwingUtilities.invokeLater(new Runnable () {
            public void run () {               
                Canvas canvas = JmeClientMain.getFrame().getCanvas();
                if (!canvas.requestFocusInWindow()) {
                    logger.info("Focus request for main canvas rejected.");
                }
            }
        });
    }
View Full Code Here

                Math.abs((fromLoc.z)-(toLoc.z))<=150) {
            //Cover Screen not needed
        } else {
            //attach cover screen
            final MainFrame mainFrame =  JmeClientMain.getFrame();
            final Canvas canvas = mainFrame.getCanvas();
            final CoverScreen coverScreenPanel = new CoverScreen(csd,canvas.getSize());
           
            try {
                //show cover screen in JDialog over the canvas panel
                SwingUtilities.invokeLater(new Runnable() {

                    public void run() {
                        dialog = new JDialog(mainFrame.getFrame(), "Child", false);
                        coverScreenPanel.setPreferredSize(canvas.getSize());
                        dialog.setSize(canvas.getSize().width
                                ,canvas.getSize().height);
                        dialog.setLocation(canvas.getLocationOnScreen().x
                                ,canvas.getLocationOnScreen().y);
                       
                        mainFrame.getFrame().addComponentListener(new ComponentAdapter() {

                            private void doChange() {
                                SwingUtilities.invokeLater(new Runnable() {
                                    public void run() {
                                        if (dialog != null && dialog.isVisible()) {
                                            Component cs = dialog.getComponent(0);
                                            Canvas canvas = mainFrame.getCanvas();
                                            cs.setPreferredSize(canvas.getSize());
                                            dialog.setSize(canvas.getSize().width, canvas.getSize().height);
                                            dialog.setLocation(canvas.getLocationOnScreen().x, canvas.getLocationOnScreen().y);
                                            dialog.pack();
                                            dialog.setVisible(true);
                                        }
                                    }
                                });
View Full Code Here

            // No more apps have control. Reenable global (world) listeners.
            inputManager.addKeyMouseFocus(inputManager.getGlobalFocusEntity());

            // Make sure the main canvas gets keyboard focus
            updateKeyFocus(false);
            Canvas canvas = JmeClientMain.getFrame().getCanvas();
            if (!canvas.requestFocusInWindow()) {
                logger.info("Focus request for main canvas rejected.");
            }
        }
    }
View Full Code Here

     * this behavior.
     * @param hasControl true if the app has just gained control, or false if
     * not
     */
    protected void updateKeyFocus(boolean hasControl) {
        Canvas canvas = JmeClientMain.getFrame().getCanvas();

        if (!hasControl) {
            // Make sure that the main canvas is focusable
            canvas.setFocusable(true);
        } else {
            // Prevent the main canvas for gaining focus while an app has focus
            canvas.setFocusable(false);
        }
    }
View Full Code Here

            } catch (HeadlessException he) {
                // ignore
                logger.log(Level.INFO, "Running in headless mode");
            }
            canvasPanel = new JPanel(new BorderLayout());
            canvas = new Canvas();

            canvasPanel.add(canvas, BorderLayout.CENTER);

            if (frame != null) {
                frame.setContentPane(canvasPanel);
View Full Code Here

TOP

Related Classes of java.awt.Canvas$AccessibleAWTCanvas

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.