本人一小菜鸟,学习JAVA   APPLET中,请问各位大虾如何实现点击一个BUTTON产生一个弹出窗口显示一幅固定的图片?? 求教具体代码
估计问题比较弱,不过还是希望大虾不吝赐教=。=

解决方案 »

  1.   

    Java\jdk1.5.0_04\demo\applets在你安装的JDK文件下有示例 可以看一下!  点BUTTON 就是一个事件 然后显示图片 可以用TOOLKIT
      

  2.   

    JAVA  APPLET 都不怎么用了.怎么还有人学啊...
    他已经由Flash所代替了
      

  3.   

    按钮事件就不说了。applet 初始化的时候,读入图像到image 对象
    Image backImage;
    backImage=getImage(getCodeBase(),"ok.gif");
    需要显示的时候
    在paint() 方法里面写
     g.drawImage(backImage,0,0,this);========================================
    反对二楼的说法
      

  4.   

    帮你写好了.你的图片放在一个目录(图片名为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); }
    }
    }