1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Bouton22 extends Applet implements ActionListener
{
String msg=" ";
Button click;
Button press;
public void init()
{
click=new Button("Click-me");
add(click);
click.addActionListener(this);
press=new Button("Pressez");
add(press);
press.addActionListener(this);
setBackground(Color.gray);
setForeground(Color.black);
}
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
if(str.equals("CLick-me"));
{
msg="You pressed the button.";
}
else
if(str.equals("Pressez"));
{
msg="Vous avez appuyez sur le bouton.";
}
repaint();
}
public void paint (Graphics g)
{
g.drawString(msg,80,100);
}
} |
Partager