求教一个关于JAVA applet的一个基础问题? 本人一小菜鸟,学习JAVA APPLET中,请问各位大虾如何实现点击一个BUTTON产生一个弹出窗口显示一幅固定的图片?? 求教具体代码估计问题比较弱,不过还是希望大虾不吝赐教=。= 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Java\jdk1.5.0_04\demo\applets在你安装的JDK文件下有示例 可以看一下! 点BUTTON 就是一个事件 然后显示图片 可以用TOOLKIT JAVA APPLET 都不怎么用了.怎么还有人学啊...他已经由Flash所代替了 按钮事件就不说了。applet 初始化的时候,读入图像到image 对象Image backImage;backImage=getImage(getCodeBase(),"ok.gif");需要显示的时候在paint() 方法里面写 g.drawImage(backImage,0,0,this);========================================反对二楼的说法 帮你写好了.你的图片放在一个目录(图片名为5.gif或自己名字).没有问题及时结贴.import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Test extends JFrame implements ActionListener{ JPanel p=new JPanel(); JLabel l1=new JLabel("请点按钮"); JButton b1=new JButton("点击我"); public Test() { p.add(l1); p.add(b1); b1.addActionListener(this); this.setSize(600,200); this.setTitle("测试"); this.setContentPane(p); this.setDefaultCloseOperation(EXIT_ON_CLOSE); } public void actionPerformed(ActionEvent e) { if(e.getSource().equals(b1)) { this.setVisible(false); Test1 t1=new Test1(); t1.setVisible(true); } } public static void main(String[] args){ Test t=new Test(); t.setVisible(true); Test1 t1=new Test1(); t1.setVisible(false); }}class Test1 extends JFrame implements ActionListener{ JPanel p=new JPanel(); JLabel l1=new JLabel(); JButton b1=new JButton("返回"); public Test1() { l1.setIcon(new ImageIcon("5.gif","中国")); p.add(l1); p.add(b1); b1.addActionListener(this); this.setSize(600,200); this.setTitle("成功"); this.setContentPane(p); this.setDefaultCloseOperation(EXIT_ON_CLOSE); } public void actionPerformed(ActionEvent e) { if(e.getSource().equals(b1)) { this.setVisible(false); Test t=new Test(); t.setVisible(true); } }} 关于泛型List<?>能不能这样??? 新手求助 嵌套HashMap 存放三元组的问题 求解关于java参数传递的问题一道 JAVA+数据库问题 请教一下:在Java中计算汉字长度的问题? 帮忙检查一下这个程序错在哪 ? 关于SWING中的JComboBox的问题比较简单了! Jdbc还是Tomcat的错误?100分 Java 万岁!! 在JPane上加JScrollPane问题???急!!!!!!!!!!!!!!! 英雄,救命啊!java同一个包中的类怎样继承???为什么老是出错?
他已经由Flash所代替了
Image backImage;
backImage=getImage(getCodeBase(),"ok.gif");
需要显示的时候
在paint() 方法里面写
g.drawImage(backImage,0,0,this);========================================
反对二楼的说法
import java.awt.event.*;
import javax.swing.*;public class Test extends JFrame implements ActionListener{
JPanel p=new JPanel();
JLabel l1=new JLabel("请点按钮");
JButton b1=new JButton("点击我");
public Test()
{
p.add(l1);
p.add(b1);
b1.addActionListener(this);
this.setSize(600,200);
this.setTitle("测试");
this.setContentPane(p);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(b1))
{
this.setVisible(false);
Test1 t1=new Test1();
t1.setVisible(true);
}
}
public static void main(String[] args){
Test t=new Test();
t.setVisible(true);
Test1 t1=new Test1();
t1.setVisible(false);
}
}class Test1 extends JFrame implements ActionListener{
JPanel p=new JPanel();
JLabel l1=new JLabel();
JButton b1=new JButton("返回");
public Test1()
{
l1.setIcon(new ImageIcon("5.gif","中国"));
p.add(l1);
p.add(b1);
b1.addActionListener(this);
this.setSize(600,200);
this.setTitle("成功");
this.setContentPane(p);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(b1))
{
this.setVisible(false);
Test t=new Test();
t.setVisible(true); }
}
}