www.pudn.com > App.rar > App.java


import  java.applet. Applet; 
import  java.awt. event.*; 
import  java.awt.*; 
public class App extends Applet implements ActionListener 
{ 
 
 
int i=20; 
 
Label l1=new Label(); 
Label l2=new Label(); 
Label l3=new Label(); 
Panel p; 
Button b1=new Button("放大"); 
Button b2=new Button("缩小"); 
public void init () 
{ 
 
 
p=new Panel(); 
b1.addActionListener(this); 
b2.addActionListener(this); 
p.setLayout(new GridLayout(1,5)); 
this.setLayout(new BorderLayout()); 
p.add(l1); 
p.add(b1); 
p.add(l2);		 
p.add(b2); 
p.add(l3); 
add(p,"South"); 
} 
 public void paint(Graphics g){ 
Font f; 
 
//Color c; 
 
//c=new Color(r,m,b); 
 f=new Font("TimesRoman",Font.PLAIN,3+i); 
 g.setColor(Color.purple); 
 g.setFont(f); 
 g.drawString("老师辛苦了!",50,100);} 
 
public void actionPerformed(ActionEvent e) 
{ 
if(e.getActionCommand()==("放大")){ 
	i=i+5; 
	repaint(); 
} 
if(e.getActionCommand()==("缩小")) 
 
i=i-5; 
 
 
 
 
repaint(); 
} 
 
}