Code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

public class Main extends Applet implements ActionListener
{ 
Panel p = new Panel();
JButton admin = new JButton ("Admin");
JButton user = new JButton ("User");
JPanel TextField = new JPanel();
JTextField username = new JTextField(10);

public void init()
{ 
 setSize(400,400);
 MainMenu();
 UserPass();
   

}

public void MainMenu()
{

 setLayout(new BorderLayout());

 p.add(admin);
 p.add(user);
 add(p, BorderLayout.SOUTH);
 
 admin.addActionListener(this);
 user.addActionListener(this);

}

public void UserPass()
{

 TextField.setLayout(new BorderLayout(5,0));
 TextField.add(new JLabel("Username : "), BorderLayout.WEST);
 TextField.add(username, BorderLayout.CENTER);
                               add(TextField);

}

public void actionPerformed(ActionEvent e)
{

 if (e.getSource() == admin)
 {
     remove(p);
 }
 
 if (e.getSource() == user)
 {
     remove(p);
 }

}
}
can somebody help me..as you can see, if the e.getSource() == admin, it will remove the object p from class Panel...now after it remove the object p, i want the applet to invoke the method UserPass()...the problem is when i put something like this :-

Code:
if (e.getSource() == admin)
 {
     remove(p);
     UserPass();
 }
it would not invoke the UserPass() but when i put the UserPass in public void init(), it easily invoked the UserPass method but the problem is it would produce the output the button named Admin and User as well as the Username : and a textfield synchronously....

i dont want that kind of output...i want if a user click the button Admin or User, then it will show up the Username : and the text field...can somebody help me solve this problem