重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
看了一下,觉得没问题,肯定能运行起来 ,要不把你的一场贴出来,看看异常报在什么地方。好像画了五个环,奥运会啊
创新互联建站专业为企业提供连云港网站建设、连云港做网站、连云港网站设计、连云港网站制作等企业网站建设、网页设计与制作、连云港企业网站模板建站服务,10多年连云港做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import chrriis.common.UIUtils;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer;
/**
* @author Christopher Deckers
*/
public class SimpleFlashExample extends JPanel {
public SimpleFlashExample() {
super(new BorderLayout());
JFlashPlayer flashPlayer = new JFlashPlayer();
flashPlayer.load(getClass(), "resource/Movement-pointer_or_click.swf");
add(flashPlayer, BorderLayout.CENTER);
}
/* Standard main method to try that test as a standalone application. */
public static void main(String[] args) {
UIUtils.setPreferredLookAndFeel();
NativeInterface.open();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("DJ Native Swing Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new SimpleFlashExample(), BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
});
NativeInterface.runEventPump();
}
}
一个简单的范例,不明白追问吧
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class MoveAnimationDemo extends JFrame {
public MoveAnimationDemo() {
this.setContentPane(new AnimationPanel());
this.setSize(500, 500);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
/**
* 开始动画
*/
public void startAnimation() {
// 设定初始条件
x = START_X;
y = START_Y;
// 创建计时器
timer = new Timer(DELAY_TIME, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// 每一次延迟过后,调用一次
x += 1;
y += 1;
repaint();
// 满足结束条件就停止
if (x = END_X || y = END_Y) {
timer.stop();
}
}
});
// 开启计时器
timer.start();
}
public static void main(String[] args) {
MoveAnimationDemo demo = new MoveAnimationDemo();
demo.setVisible(true);
demo.startAnimation();
}
private class AnimationPanel extends JPanel {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(CIRCLE_COLOR);
g.fillOval(x, y, CIRCLE_SIZE, CIRCLE_SIZE);
}
}
// 圆点颜色
private static final Color CIRCLE_COLOR = Color.RED;
// 圆点大小
private static final int CIRCLE_SIZE = 10;
// 起始位置
private static final int START_X = 50;
private static final int START_Y = 50;
// 终止位置
private static final int END_X = 400;
private static final int END_Y = 400;
// 动画帧之间的延时,每秒60帧
private static final int DELAY_TIME = 1000 / 60;
// 当前位置
private int x;
private int y;
private Timer timer;
}
感觉这应该是前端页面的功能吧,不是后端做的事情。是让照片以幻灯片的方式呈现,这是纯页面效果,后台只负责推送数据,怎么展现是前端的活了吧。
用Java画动画很简单,让一个线程自己定时调用自己即可,记得要设置一个退出(结束)条件。
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class Animation {
final static int DELAY = 500;
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final Text text = new Text(shell, SWT.BORDER);
text.setText("0");
new Runnable() {
public void run() {
if (shell.isDisposed())
return;
text.setText("" + (Integer.parseInt(text.getText()) + 1));
Display.getDefault().timerExec(DELAY, this);
}
}.run();
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}