This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line!
See this thread for details.
Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Error

 
Ranch Hand
Posts: 1325
1
  • 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());

}
}






}
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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?

 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic