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

Creating a VolatileImage with size 0,0 results in no longer working g2d.drawString

XMLWordPrintable

    • 2d
    • b100
    • x86_64
    • linux_ubuntu

        FULL PRODUCT VERSION :
         1.8.0_60

        ADDITIONAL OS VERSION INFORMATION :
        Linux augusta 3.19.0-26-generic #28-Ubuntu SMP Tue Aug 11 14:16:32 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        NVIDIA Corporation GK104 [GeForce GTX 670]
        Nvidia binary driver: nvidia-355


        A DESCRIPTION OF THE PROBLEM :
        When creating a VolatileImage with size 0/0 (which does not throw an exception), there are surprising side effect:

        All texts drawn on a graphics context do not longer show up.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        - Create a VolatileImage with size 0,0
        - Draw a String on a graphics context (g2d.drawString)



        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        IllegalArgumentException(?)
        ACTUAL -
        No exception is thrown.
        Strings are no longer visible when using Graphics2D#drawString

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
         System.out.println("Java Version: " + System.getProperty("java.version"));

            GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice device = env.getDefaultScreenDevice();

            //if size is set to 0 the string is not visible in Linux (with nvidia binary driver)
            int size = 0;
            VolatileImage volatileImage = device.getDefaultConfiguration().createCompatibleVolatileImage(size, size); //This image is never used


            JFrame frame = new JFrame();

            frame.getContentPane().add(new JComponent() {
              @Override
              protected void paintComponent(Graphics g) {
                super.paintComponent(g);

                g.setColor(Color.RED);
                ((Graphics2D) g).drawString("Hello World", 10, 20);
              }
            });

            frame.setSize(800, 600);
            frame.setVisible(true);
        ---------- END SOURCE ----------

              psadhukhan Prasanta Sadhukhan
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: