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

Different results in Solaris vs. Win95 for painting on top of a button.

XMLWordPrintable

    • 1.1
    • sparc
    • solaris_2.4
    • Not verified


      Overriding paint() for a Component (Button) that already knows how to
      paint itself via a ComponentPeer gives different results in Solaris
      versus Win95. The code below attempts to paint a red line on top of a
      native button. The red line appears initially and on window exposes
      in Solaris, but never shows up in Win95.


      ================ PaintExample.html ================

      <html>
      <head>
      <title>PaintExample</title>
      </head>

      <body>
      The PaintExample applet:
      <applet code="PaintExample.class" width=200 height=200>
      </applet>

      </body>
      </html>

      ================ PaintExample.java ================

      import java.awt.*;

      /**
       * PaintExample -- defining/overriding paint() in Component subclasses
       */
      public class PaintExample extends java.applet.Applet {

          public void init() {
      MyPaintButton b = new MyPaintButton("a button");
      add(b);
          }
      }


      /**
       * A Button subclass that draws a red line across the normal Button image.
       */
      class MyPaintButton extends Button {

          public MyPaintButton(String s) {
      super(s);
          }

          public void paint(Graphics g) {
      super.paint(g); /* draw as a regular Button first */
      g.setColor(Color.red);
      g.drawLine(6, size().height / 2, size().width - 6, size().height / 2);
          }
      }


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

            tballsunw Tom Ball (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: