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

Method Graphics.drawString() draws unnecessary dot

XMLWordPrintable

    • 2d
    • x86
    • linux



      Name: kaC94536 Date: 01/19/2000



      Graphics.drawString() method does not work correctly when environment variable
      JAVA2D_USEPLATFORMFONT is not set.
      Frame window of the following test contains container in container panel. This container
      in its own paint(Graphics) method invokes Graphics.drawString().
      When system environment variable JAVA2D_USEPLATFORMFONT is not set, you can see
      a dot on the left upper corner of the container.

      The same behavior is observed on Solaris.

      As we see from JDK note, variable JAVA2D_USEPLATFORMFONT is now deprecated and will be
      removed in the next build.

      --------------------test.java---------------------------------------------
      import java.awt.*;

      class ctr extends Container {
         public void paint(Graphics g) {
            g.drawString("Lightweight Container", 10, getSize().height/2);
         }
         
         public Dimension getPreferredSize() {
            return new Dimension(165, 40);
         }
      }

      public class test extends Frame {
         static Frame testFrame = null;
         static Panel containerPanel;
         
         public static void main(String[] argv) {
            testFrame = new Frame("Lightweight Container Test");
            testFrame.setSize(200, 100);
            
            containerPanel = new Panel();
            containerPanel.add(new ctr());
            
            testFrame.add("Center", containerPanel);
            testFrame.setVisible(true);
         }
      }
      ----------------------------------------------------------------------
      $ java -version
      java version "1.2.2"
      Classic VM (build 1.2.2-L, green threads, javacomp)

      ======================================================================

      ======================================================================

            Unassigned Unassigned
            kanisimosunw Konstantin Anisimov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: