Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error

 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i run below code applet started.
after i click any of the button nothing print to the console.
why is that?




package aruna;


import java.applet.*;
import java.awt.Button;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MyApplet extends Applet implements ActionListener{

private Button Send;
private Button Exit;
private Button Clear;

public MyApplet()
{

}

public void init()
{
Send=new Button("Send");
Exit=new Button("Exit");
Clear=new Button("Clear");

add(Send);
add(Exit);
add(Clear);
}



public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==Send){

System.out.println(e.getSource());

}else if(e.getSource()==Exit){
System.out.println(e.getSource());

}else if(e.getSource()==Clear){
System.out.println(e.getSource());

}
}






}
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aruna,

Please use http://faq.javaranch.com/java/UseCodeTags.

You have not registered the buttons as the event source with the Applet.
Just curious. Why are you using Applet instead of JApplet?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic