Can't make buttons work!!

wxdqz

New Member
So, I started writing my first applet...step by step.Made text appear..cheanged the color.. made it ask the html for height andwidth...added a button..But now I'm stuck I can't make the button DO anything!Please help.Here is the unfinished code, I know the last part isn't correct...that'swhere my problem is!!import java.applet.Applet;import java.awt.*;import java.awt.event.*;public class MemoryApplet extends Applet{String text="This is from Memory!!";public void init(){setBackground(Color.red);text = "This is from Memory!!";Button b;b = new Button("Click!");add(b);}public void paint(Graphics g){g.setColor(Color.blue);g.drawRect(0, 0,getSize().height -1,getSize().width -1);g.setColor(Color.black);g.drawString(text, 100, 100);}class MyMouseAdapter extends MouseAdapter{public void mouseClicked (MouseEvent e){if (e.mouseClicked);{Button c;c = new Button("YEAH!!");add(c);}}}
 
Back
Top