import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends Applet implements ActionListener
{
Image im1,im2,im3;
Button button1=new Button("图一");
Button button2=new Button("图二");
Button button3=new Button("图三");
Button button4=new Button("清除");
public void init()
{
setLayout(new BorderLayout(0,0));
im1=getImage(getCodeBase(),"01.jpg");
im2=getImage(getCodeBase(),"02.jpg");
im3=getImage(getCodeBase(),"03.jpg");
add("North",button1);
add("West",button2);
add("East",button3);
add("South",button4);
button1.addActionListener(this);
button2.addActionListener(this);
button3.addActionListener(this);
button4.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(this,"hello world");
button1.setLabel("asd");
Graphics g =getGraphics();
if(e.getSource()==button1)
g.drawImage(im1,0,0,this);
else if(e.getSource()==button2)
g.drawImage(im2,0,0,this);
else if(e.getSource()==button3)
g.drawImage(im3,0,0,this);
else repaint();
}
}
6 个解决方案
#1
什么问题,能具体说明一下吗?
#2
就是按下按钮以后对话框不能弹出来了!
JOptionPane.showMessageDialog(this,"hello world");
JOptionPane.showMessageDialog(this,"hello world");
#3
为什么啊? zhaolizu(一族)
#4
为什么啊? zhaolizu(一族)
#5
他是SWING的控件在APPLET里好像不好使吧
应该用DIALONG吧
应该用DIALONG吧
#6
别的效果(比如:button1.setLabel("asd");)都出来了吗?
#1
什么问题,能具体说明一下吗?
#2
就是按下按钮以后对话框不能弹出来了!
JOptionPane.showMessageDialog(this,"hello world");
JOptionPane.showMessageDialog(this,"hello world");
#3
为什么啊? zhaolizu(一族)
#4
为什么啊? zhaolizu(一族)
#5
他是SWING的控件在APPLET里好像不好使吧
应该用DIALONG吧
应该用DIALONG吧
#6
别的效果(比如:button1.setLabel("asd");)都出来了吗?