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

Win32 only: Frame or Window redraws awkwardly.

XMLWordPrintable

    • generic, x86
    • generic, windows_nt

      When setLocation() moves a Frame or a Window, they
      redraw. They didn't in the April 8th release of JDK1.1.2. but 1.1.2D.

      Run the following code and hit RETURN on Frame to observe a problem.

      // Sample Program for JDK1.1.2D bug
      // When setLocation() moves a Frame or a Window, they redraw

      import java.awt.*;
      import java.awt.event.*;

      public class WndTest extends Frame{
              
              static final Color[] colors = {Color.red,Color.green,Color.blue};
              
              static final int[] xxx = {100,110,120,130,140};
              static final int[] yyy = {100,110,120,130,140};
              int index = 0;
              public WndTest(){
                      enableEvents(AWTEvent.KEY_EVENT_MASK|AWTEvent.WINDOW_EVENT_MASK);
              }
              
              public void paint(Graphics gc){
                      Dimension size = getSize();
                      Insets insets = getInsets();
                      Dimension rsize = new Dimension(size.width - (insets.left+insets.right),
                                                                                      size.height - (insets.top+insets.bottom));
                      
                      for(int ii = 0; ii < colors.length; ii++){
                              gc.setColor(colors[ii]);
                              gc.fillOval(insets.left, insets.top,rsize.width, rsize.height);
                              try{
                                      Thread.currentThread().sleep(200);
                              }catch(Exception e){}
                      }
              }
              
              public void processKeyEvent(KeyEvent ev){
                      if(ev.getID() == KeyEvent.KEY_PRESSED){
                              if(ev.getKeyCode() == KeyEvent.VK_ENTER){
                                      ++index;
                                      if(index >= xxx.length)
                                              index = 0;
                                      setLocation(xxx[index], yyy[index]);
                              }
                      }
              }
              public void processWindowEvent(WindowEvent ev){
                      if(ev.getID() == WindowEvent.WINDOW_CLOSING)
                              System.exit(0);
                      super.processWindowEvent(ev);
              }

              public static void main(String args[]){
                      WndTest me = new WndTest();
                      me.pack();
                      me.setBounds(100,100,400,400);
                      me.setVisible(true);
              }
      }

            rraysunw Richard Ray (Inactive)
            sishidasunw Shoji Ishida (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: