我想知道用Jbuilder能实现如下效果吗??

来源:百度知道 编辑:UC知道 时间:2024/06/18 09:54:30
开始实习了 要做个小游戏
想实现如下效果 随着游戏的进行 游戏窗口会不停的震动
请问可以实现吗 用Jbuilder 代码要是有就更好了
高分悬赏啊

// 用 JFrame 做了个演示,有知能否帮到你
///: File JF.java

import java.awt.Point;
import java.awt.event.*;
import javax.swing.*;
public class JF extends JFrame implements MouseListener{
int i=0;//震动方向
int c=0;//震动计数器
int total = 30;//震动持续次数
int dist = 6;//震动剧烈程度
public JF(){
super("在我的里面点点看吧,我会动哦~~");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setAlwaysOnTop(true);
this.setSize(600,400);
this.setLocationRelativeTo(null);
this.addMouseListener(this);
this.setVisible(true);
}
private void shake() {
new Thread(){
public void run(){
i=0;c=0;
Point p = getLocation();
while(c++<total){
switch(i++%4){
case 0:setLocation(p.x+dist,p.y-dist);
break;
case 1:setLocation(p.x-dist,p.y+dist);
break;
case 2:setLocation(p.x+dist,p.y+dist);
break;