aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Applet" Watch "Applet" New topic
Author

Applet

Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
Actualy sir what's wrong with following code , i would like to see working of ActionPerformed function but it is not working. Mean ActionPerformed function is not calling by ActionListner why why why?pls help.


import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class first extends Applet implements ActionListener{
Button btn=new Button("Maalik");
Button btn1=new Button("Arun");
public void init(){

add(btn);

btn.addActionListener(this);
}

public void actionPerformed(ActionEvent ae){

add(btn1);


}


}
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Hi Arun,

this is your second post with the subject "Applet" - how are we going to tell which one is which in the forum overview? In fact this isn't even an Applet question, but a generic Swing question. Please take some time to compose a meaningful subject line when posting a question, that will safe all those people who'd like to help you a lot of time, and therefore simply would be an act of respect. See http://faq.javaranch.com/view?UseAMeaningfulSubjectLine

You can change the subject line by clicking the edit icon on your very first post of the thread.

Moving this and your other post to the Swing forum.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

When you add a component to a container that's already visible on the screen, you must call validate() on the container afterwards. Until you do, the new component won't appear. Since here the applet itself is the container, just add the line

validate();

at the end of the event handler.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet