winform技巧—窗体抖动代码

 private void shakeWindow()
 {
  int x = this.getX();
  int y = this.getY();
  
  for (int i = 0; i < 35; i++)
  {
        if ((i % 2) == 0) {
            x += 5;
            y += 5;
        } else {
           x -= 5;
           y -= 5;
        }
       this.setLocation(x, y);
       try {
         Thread.sleep(40);
        } catch (InterruptedException e1) {
          e1.printStackTrace();
       }
     }
 }

你可能感兴趣的:(winform技巧—窗体抖动代码)