java中加入动态图片 各位大侠,我想用java做一个小游戏,想在当中加入动态的效果, 但是不知道怎么做,望各位大侠指导!!! 还有就是那个点击按钮以后出现界面的切换,那种从一边抽走的效果是怎么做出来的啊 ??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你要写游戏可以下看看别人的 这个论坛就有很多 有一个好像叫 300行的 俄罗斯方块 你可以看看你这个效果估计得自己画 用添加一个panel 获得graphic画上再刷新等 想不闪烁还得用双缓冲 import java.io.IOException;import javax.swing.*;import java.awt.*;import java.awt.image.*;import java.io.File;import javax.imageio.ImageIO;public class NewClass { JFrame frame; JPanel contentPane; BufferedImage image; int x; public NewClass(){ try { image = ImageIO.read(new File("1.jpg"));//此文件在当前目录下 x=0; frame = new JFrame(); contentPane = new JPanel() { public void paint(Graphics g) { int width=this.getWidth(); int height=this.getHeight(); g.setColor(Color.white); g.fillRect(0, 0, width, height); g.drawImage(image, x, 0, null); } }; contentPane.setPreferredSize(new Dimension(600,600)); frame.setContentPane(contentPane); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); new Thread(){ public void run(){ while(true){ try { Thread.sleep(20); x+=10; if(x>600){ x=0; } contentPane.repaint(); } catch (InterruptedException ex) { ex.printStackTrace(); } } } }.start(); } catch (IOException ex) { ex.printStackTrace(); } } public static void main(String args[]){ new NewClass(); }} 在一个按钮中同时添加了两个ActionListener对象会怎样 不明白这个什么意思test.split("\s") 如何成为JAVA高手 【求助】关于 LinkedList 的一个问题 (不胜感激啊。。。) vf数据库连接的问题~~~~~~~~~~~~~~~~~~~~请高手指教 刚学java..碰到问题啦..各位大虾帮个忙..谢啦.. JDK设置环境变量的问题 菜鸟的问题(见笑了) 提个简单的问题,新手,刚学java java入门问题,谢谢回答 求助解决不能重复积分 吸血鬼数字
import java.io.IOException;
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import java.io.File;
import javax.imageio.ImageIO;
public class NewClass {
JFrame frame;
JPanel contentPane;
BufferedImage image;
int x;
public NewClass(){
try {
image = ImageIO.read(new File("1.jpg"));//此文件在当前目录下
x=0;
frame = new JFrame();
contentPane = new JPanel() {
public void paint(Graphics g) {
int width=this.getWidth();
int height=this.getHeight();
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
g.drawImage(image, x, 0, null);
}
};
contentPane.setPreferredSize(new Dimension(600,600));
frame.setContentPane(contentPane);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
new Thread(){
public void run(){
while(true){
try {
Thread.sleep(20);
x+=10;
if(x>600){
x=0;
}
contentPane.repaint();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
}.start();
} catch (IOException ex) {
ex.printStackTrace();
}
}
public static void main(String args[]){
new NewClass();
}
}