底下是我写的程序,我感觉越改越不对,现在插入其他东西时连按钮都显示不出来了package mxcx;
import java.applet.Applet;import java.awt.*;import java.awt.event.*;import javax.swing.ImageIcon;
import javax.swing.JPanel;public class AppletDemo extends Applet{
private Button btn1,btn2;
private Image logo1;
private ImageIcon logo2;
private Panel mb1,mb2;
private Component Image;
private Component ImageIcon;
public void init() {
logo1=getImage(getDocumentBase(),"img/会呼吸的痛[1].jpg");
logo2=new ImageIcon("img/樱野3加1[1].jpg");
btn1=new Button("会呼吸的痛");
btn2=new Button("再次相信");
add(btn1);
add(btn2);
setSize(500, 100);
this.setLayout(new GridLayout(2,2));
//当按钮被按下时, 事件处理 btn1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {
}
});
}
//public void paint(Graphics g){
//g.drawImage(logo1, 0, 0, this);
//g.drawImage(logo1, 0, 120, getWidth(), getHeight()-120, this);
//logo2.paintIcon(this, g, 180, 0);
//}
public static void main(String[] args) {
AppletDemo sd=new AppletDemo(); new Applet().setVisible(true);
}
AppletDemo(){
mb1=new Panel();
mb2=new Panel();
mb1.add(Image);
mb1.add(ImageIcon);
mb2.add(btn1);
mb2.add(btn2);
this.add(mb1);
this.add(mb2);
}
}
import java.applet.Applet;import java.awt.*;import java.awt.event.*;import javax.swing.ImageIcon;
import javax.swing.JPanel;public class AppletDemo extends Applet{
private Button btn1,btn2;
private Image logo1;
private ImageIcon logo2;
private Panel mb1,mb2;
private Component Image;
private Component ImageIcon;
public void init() {
logo1=getImage(getDocumentBase(),"img/会呼吸的痛[1].jpg");
logo2=new ImageIcon("img/樱野3加1[1].jpg");
btn1=new Button("会呼吸的痛");
btn2=new Button("再次相信");
add(btn1);
add(btn2);
setSize(500, 100);
this.setLayout(new GridLayout(2,2));
//当按钮被按下时, 事件处理 btn1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {
}
});
}
//public void paint(Graphics g){
//g.drawImage(logo1, 0, 0, this);
//g.drawImage(logo1, 0, 120, getWidth(), getHeight()-120, this);
//logo2.paintIcon(this, g, 180, 0);
//}
public static void main(String[] args) {
AppletDemo sd=new AppletDemo(); new Applet().setVisible(true);
}
AppletDemo(){
mb1=new Panel();
mb2=new Panel();
mb1.add(Image);
mb1.add(ImageIcon);
mb2.add(btn1);
mb2.add(btn2);
this.add(mb1);
this.add(mb2);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货