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

Placement of drawString can make other draw calls not appear under GDI

XMLWordPrintable

    • 2d
    • x86
    • windows_95

      Build : 'L'
      OS : Win95/98 (WinNT ok, Sol ok)
      drawmode: GDI (-Dsun.java2d.noddraw=true) only (DirectDraw ok)
      app : included below.

      Any draw calls placed _after_ a drawString will not draw.


      import java.awt.*;
      import java.awt.geom.*;
      import java.awt.event.*;
      import java.awt.image.BufferedImage;


      public class drawStringBug extends Frame {

       private TextCanvas c;

       public static void main(String args[]) {
      WindowListener wnd = new WindowAdapter() {
      public void windowClosing(WindowEvent e) {System.exit(0);}
      };
          drawStringBug f = new drawStringBug();
      f.setSize(400,650);
          f.show();
       }
          
       public drawStringBug() {
          c = new TextCanvas();
          add("Center", c);
       }

      }

       class TextCanvas extends Canvas {

          public void paint(Graphics g) {
      Graphics2D g2 = (Graphics2D)g;

      // Place the below block after all other draws to make other draw.
      g2.setColor(Color.black);
      g2.drawString("drawString", 20, 20);

      g2.setColor(Color.black);
      g2.setFont(new Font("Dialog", Font.PLAIN, 18));
      g2.drawString("drawString:Dialog:PLAIN:18", 20, 550);
      g2.setFont(new Font("Dialog", Font.BOLD, 18));
      g2.drawString("drawString:Dialog:BOLD:18", 20, 580);

      Image im = createImage(50,50);
      Graphics ig = im.getGraphics();
      ig.setColor(Color.red);
      ig.fillRect(0,0,50,50);
      g.drawImage(im, 100,10, this);

      for (float f = 1; f < 10.0f; f++) {
      g2.setStroke(new BasicStroke(f));
      GeneralPath p = new GeneralPath();
      p.moveTo(210, 10+(f*10));
      p.lineTo(380, 10+(f*10));
      p.closePath();
      g2.draw(p);
      }

      GradientPaint gp = new GradientPaint(0.0f, 0.0f, Color.blue, 185.0f, 213.0f, Color.white);
      g2.setPaint(gp);
      g2.fillRect(20, 80, 185, 213);


           }

      public Dimension getPreferredSize() {
              return new Dimension(400, 650);
      }

      }

            prr Philip Race
            rckim Robert Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: