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

Graphics's methods does not draw when the first mouse event come.

    XMLWordPrintable

Details

    • x86
    • windows_nt

    Description



      Name: rlT66838 Date: 07/16/99


      Hi.
      It is so hot in South Korea.
      My name is Sung-eun Yang. Glad to meet you.

      * I have found a problem, using Graphics's method, seem to be a bug.

      Following simple example code is proposed to be act below.
       1. At the beginning of its run, nothing will be painted in the Frame.
       2. Once you press a mouse button inside the Frame, a red filled Box would appear.

        import java.awt.*;
        import java.awt.event.*;
        public class Test extends Component {
         public Test() {
           enableEvents(AWTEvent.MOUSE_EVENT_MASK);
         }
         public void processMouseEvent(MouseEvent e) {
           if (e.getID() == MouseEvent.MOUSE_PRESSED) {
             System.out.println("mouse pressed");
             Graphics g = getGraphics();
             g.setColor(Color.red);
             g.fillRect(10,10,50,50);
           }
         }
         public static void main(String[] args) {
           Frame f = new Frame();
           f.add(new Test());
           f.setLocation(300,450);
           f.setSize(200,150);
           f.setVisible(true);
         }
        }

      * Problem is: *
       The drawing methods of Graphics -fillRect()... - didn't any effective work(anything)
          on it's first call involved by first mouse pressing.
       but, on it's second call, these methods did work properly.

       Mouse event was properly delivered, thus I think that the methods of Graphics
       contain bug...

      *[java -version]
        java version "1.2.1"
        Classic VM (build JDK-1.2.1-A, native threads)

      * windows NT 4 (Service pack 3)

      Please, reply to me.
      Have a nice day.
      Thanks.
      (Review ID: 85676)
      ======================================================================

      Attachments

        Activity

          People

            rraysunw Richard Ray (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: