Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4660250

setFullSceenWindow yields window at Rectangle(1,1,scr_wdth, scr_hght)

    Details

    • Subcomponent:
    • Introduced In Build:
      5.0
    • Introduced In Version:
      5.0
    • CPU:
      sparc
    • OS:
      solaris_8

      Description

      Name: gm110360 Date: 03/29/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      SunOS wolverine 5.8 Generic_108528-07 sun4u sparc
      SUNW,Sun-Blade-100

      A DESCRIPTION OF THE PROBLEM :
      The documentation for setFullScreenWindow states that it
      will attempt to simulate a full screen window in the case
      that full screen exclusive mode is not supported on a given
      machine. I have a machine that supports full screen mode,
      and a machine that does not. I am finding that on my
      machine that does NOT support full screen mode, the window
      that results from the call to setFullScreenWindow is almost
      full sceen, but is off by one pixel in the x and y
      directions. So instead of being at
      Rectangle(0,0,screen_width,screen_height), it is at
      Rectangle(1,1,screen_width,screen_height). This means that
      I loose pixels when I am painting near the edge of the
      screen, that I can see the pixels for the desktop behind,
      etc. I have tried various combinations of setLocation and
      setBounds with no results. The best that I can doe is get
      the getBounds to report the desired rectangle; however, the
      window's position did not actually change.

      It all seems to work fine if the machine supports full
      screen exclusive mode.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I expect a window that covers the entire screen, no more
      (meaning not a window beyond the edges) and no less (meaning
      not a window that leaves some of the desktop uncovered). I
      cannot seem to get on using this scenario.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * FullScreenWnd.java
       *
       * Created on March 28, 2002, 8:59 AM
       */

      import java.awt.*;
      import java.awt.image.*;



      /**
       * full screen exclusive mode
       *
       */
      public class FullScreenWnd extends javax.swing.JFrame {

      // window resources
      private GraphicsDevice m_oGraphicsDevice;
      private DisplayMode m_oOrigDisplayMode;

      // paint resources
      private BufferStrategy m_oPaintBuffers;
      private Color[] m_oColors = {
      Color.blue,
      Color.cyan,
      Color.green,
      Color.magenta,
      Color.orange,
      Color.pink,
      Color.red,
      Color.yellow,
      Color.white
      };

      // update cycle variables
      private Thread m_oUpdateCycle;
      private boolean m_bContinueUpdateCycle = true;

      /** Creates new form FullScreenWnd */
          public FullScreenWnd ()
      {
      GraphicsEnvironment oGraphicsEnvironment =
      GraphicsEnvironment.getLocalGraphicsEnvironment();
      m_oGraphicsDevice = oGraphicsEnvironment.getDefaultScreenDevice();

      getContentPane().setIgnoreRepaint(true);
      initComponents();

      // attempt to make this a full screen window
      // function supposed to emulate fullscreen if device does not support it
      m_oGraphicsDevice.setFullScreenWindow(this);

      // attempt to optimize our display mode (resolution, colors, refresh rate)
      if (m_oGraphicsDevice.isDisplayChangeSupported()) {
      DisplayMode oDesirableDisplayMode = getBestDisplayMode(m_oGraphicsDevice);
      if (oDesirableDisplayMode != null) {
      m_oOrigDisplayMode = m_oGraphicsDevice.getDisplayMode(); // save for
      cleanup purposes
      m_oGraphicsDevice.setDisplayMode(oDesirableDisplayMode);
      }
      }

      // create page flip
      createBufferStrategy(2);
      m_oPaintBuffers = getBufferStrategy();

      m_oUpdateCycle = new Thread() {
      public void run () {
      do {
      updateWnd();
      try { Thread.sleep(1000); } catch (Throwable ex) { ex.printStackTrace();
      }
      } while (m_bContinueUpdateCycle);
      }
      };
      m_oUpdateCycle.start();
      }

      /**
      * Helper function for the constructor. Called if the display mode can be
      changed.
      * Used to pick a "desirable" display mode.
      */
      private DisplayMode getBestDisplayMode (GraphicsDevice oDevice)
      {
      // for simplicity, return the current mode
      return (oDevice.getDisplayMode());
      }

      /** Reset display mode and clean up system resources used by display window */
      private void cleanup ()
      {
      // reset display mode
      if (m_oGraphicsDevice != null) {
      if (m_oOrigDisplayMode != null)
      m_oGraphicsDevice.setDisplayMode(m_oOrigDisplayMode);
      m_oGraphicsDevice.setFullScreenWindow(null);
      }

      // clean up the window itself
      dispose();
      }

          /** This method is called from within the constructor to
           * initialize the form.
           * WARNING: Do NOT modify this code. The content of this method is
           * always regenerated by the Form Editor.
           */
      private void initComponents() {//GEN-BEGIN:initComponents

      getContentPane().setLayout(null);

      setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
      setBackground(java.awt.Color.darkGray);
      setFont(new java.awt.Font("", 1, 48));
      setResizable(false);
      setUndecorated(true);
      addKeyListener(new java.awt.event.KeyAdapter() {
      public void keyTyped(java.awt.event.KeyEvent evt) {
      formKeyTyped(evt);
      }
      });

      pack();
      }//GEN-END:initComponents

      private void formKeyTyped(java.awt.event.KeyEvent evt)
      {//GEN-FIRST:event_formKeyTyped
      char chChar = evt.getKeyChar();
      if ((chChar == 'q') || (chChar == 'Q')) {
      closeAndExit();
      }
      }//GEN-LAST:event_formKeyTyped

      /**
      * updates the window
      */
      private void updateWnd ()
      {
      Graphics2D g = (Graphics2D)m_oPaintBuffers.getDrawGraphics();
      try {
      g.setColor(m_oColors[(int)(Math.random() * m_oColors.length)]);

      Rectangle rectWndBounds = getBounds();
      Rectangle rectStrBounds;

      rectStrBounds = g.getFontMetrics().getStringBounds(rectWndBounds.toString(),
      g).getBounds();
      g.drawString(rectWndBounds.toString(), 0, rectStrBounds.height);

      final String m_strQuitMsg = "Press \'Q\' to quit!";
      rectStrBounds = g.getFontMetrics().getStringBounds(m_strQuitMsg,
      g).getBounds();
      g.drawString(m_strQuitMsg,
      ((rectWndBounds.x + rectWndBounds.width) - rectStrBounds.width) / 2,
      ((rectWndBounds.y + rectWndBounds.height) - rectStrBounds.height) / 2);

      // flip the buffer (make this buffer the visible buffer)
      m_oPaintBuffers.show();
      }
      finally {
      g.dispose();
      }
      }

      /**
      * closes the window and exits the program
      */
      public void closeAndExit ()
      {
      // halt the update cycle
      m_bContinueUpdateCycle = false;
      try { m_oUpdateCycle.join(); } catch (Throwable ex) { ex.printStackTrace(); }

      // clean up window resources
      cleanup();

      // exit application
      System.exit(0);
      }

          /**
          * @param args the command line arguments
          */
          public static void main (String args[])
      {
      new FullScreenWnd().show();
      }


      // Variables declaration - do not modify//GEN-BEGIN:variables
      // End of variables declaration//GEN-END:variables

      }

      ---------- END SOURCE ----------
      (Review ID: 144776)
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              yan Yuri Nesterenko (Inactive)
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: