简体   繁体   中英

AWT components in fullscreen exclusive mode

I'm able to use fullscreen exclusive mode with normal Swing components, but for some reason when I use AWT components I only see a black screen in fullscreen mode. Under Windows7, if I switch away from the window (ALT-TAB) I see that the window preview/thumbnail renders correctly. Upon switching back into the application I get a black screen again.

Here is my test-case:

import java.awt.Canvas;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;

public class TestMain
{
  public static void main(String[] arg)
  {
    EventQueue.invokeLater(new Runnable()
    {
      @Override
      public void run()
      {
        final GraphicsDevice screen = GraphicsEnvironment.getLocalGraphicsEnvironment().
          getDefaultScreenDevice();
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        frame.getContentPane().setBackground(Color.BLUE);
        frame.getContentPane().setLayout(null);
        frame.setUndecorated(true);

        Canvas canvas = new Canvas();
        canvas.setBackground(Color.RED);
        canvas.setBounds(10, 10, 100, 100);
        frame.getContentPane().add(canvas);

        System.out.println("isFullscreenSupported=" + screen.isFullScreenSupported());
        screen.setFullScreenWindow(frame);
      }
    });
  }
}

I am running Java 1.6.0_23 under Windows7 Professional 64-bit. My video card is an ATI Radeon HD 4600. Is there something wrong with my code? My video card? The JDK itself?

Disabling the Direct3D pipeline ( -Dsun.java2d.d3d=false ) fixed the problem for me. I've filed a bug report against the JDK: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7010551

I confirm: on many computers I tried, DirectX/Direct3D can be a trap, and disabling it was the solution I was looking for. I think that some 2D and full screen features of Direct3D are incompatible with a reliable Java full screen use.

I observed several symptoms : blinking screen at start of full screen, full screen lock, component substitution at the end of full screen rather than returning to normal windowing...!

All was solved with this VM parameter.

Thanks a lot Gili

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM