title: How to display different components in a JFrame?
body: <p>I am very new to Java AWT. My question header must seem ridiculous to you, sorry about that. In my application I have three buttons which display different threads when clicked on. Now I want to add maybe a button or checkboxes or choicelist, etc when clicked on a particular button. For eg, if I click on yes button, it should display a choice list, something like that. How do I achieve something like that? Here is my code so far:</p>
  
  <pre><code>import java.awt.Button;
  
  import java.awt.Dimension;
  import java.awt.FlowLayout;
  import java.awt.Frame;
  import java.awt.Graphics;
  import java.awt.GridLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.KeyAdapter;
  import java.awt.event.KeyEvent;
  import java.awt.event.MouseAdapter;
  import java.awt.event.MouseEvent;
  import java.awt.event.WindowAdapter;
  import java.awt.event.WindowEvent;
  
  
  public class AppWindow extends Frame implements ActionListener{
      String keymsg = "Test message";
      String mousemsg = "Nothing";
      int mouseX=30, mouseY=30;
      String msg;
      public AppWindow(){
          //addKeyListener(new MyKeyAdapter(this));
          //addMouseListener(new MyMouseAdapter(this));
          addWindowListener(new MyWindowAdapter());
      }
  
      public void paint(Graphics g){
          g.drawString(msg, 150, 100);
      }
  
      //Here the window is created:
  
      public static void main(String args[]){
          AppWindow appwin = new AppWindow();
  
          appwin.setSize(new Dimension(300,200));
          appwin.setTitle("My first AWT Application");
          appwin.setLayout(new FlowLayout(FlowLayout.LEFT));
          appwin.setVisible(true);
  
          Button yes,no,maybe;
          yes = new Button("yes");
          no = new Button("no");
          maybe = new Button("maybe");
  
          appwin.add(yes);
          appwin.add(no);
          appwin.add(maybe);
  
          yes.addActionListener(appwin);
          no.addActionListener(appwin);
          maybe.addActionListener(appwin);
  
  
      }
  
      @Override
      public void actionPerformed(ActionEvent ae) {
          // TODO Auto-generated method stub
          String str = ae.getActionCommand();
          if(str.equals("yes")){
              msg = "You pressed Yes";
          }
          if(str.equals("no")){
              msg = "You pressed No";
          }
          if(str.equals("maybe")){
              msg = "You pressed Maybe";
          }
  
          repaint();
      }
  
  
  }
  
  
  class MyWindowAdapter extends WindowAdapter {
      public void windowClosing(WindowEvent we){
          System.exit(0);
      }
  }
  </code></pre>