Original written by Arthur but modified by me
GeSHi (java):
package gui;
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
/** * * @author Arthur */
public class VibratingWindow
extends JFrame {
private static final long serialVersionUID = 1L;
public VibratingWindow()
{
setTitle("Vibrating Window");
setDefaultCloseOperation
(JFrame.
EXIT_ON_CLOSE);
buttonPanel.
add(vibrateButton
); add
(buttonPanel,
BorderLayout.
SOUTH);
setSize(600, 300); setVisible(true);
{
{
vibrate();
}
});
}
private void vibrate() {
final int originalX = this.getLocationOnScreen().x;
final int originalY = this.getLocationOnScreen().y;
try {
for(int i = 0; i < 20; i++) {
setLocation(this.getLocationOnScreen().x, this.getLocationOnScreen().y + 10);
setLocation(this.getLocationOnScreen().x, this.getLocationOnScreen().y - 10);
setLocation
(this.
getLocationOnScreen().
x -
10,
this.
getLocationOnScreen().
y);
Thread.
sleep(10);
setLocation(originalX, originalY); }
}
catch (Exception err
) { err.
printStackTrace();
}
}
VibratingWindow vibrator = new VibratingWindow();
vibrator.setLocation(300, 300);
}
}
Created by GeSHI 1.0.7.20