Results 1 to 2 of 2
  1. #1
    udayforu_1986 is offline Member
    Join Date
    Aug 2008
    Posts
    1
    Rep Power
    0

    Default problem on button

    if i click majesty button
    it should disply 4 more buttons
    1)animations 2)visual effects 3)multimedia 4)server based

    but not showing

    my code is
    Java Code:
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    class Demoframe extends Frame implements ActionListener
    {
    Button b1,b2,b3,b4,cb1,cb2,cb3,ad1,ad2,ad3,m1,m2,m3,m4;
    Panel p,p2,p3,p4,p5,p6,p7,p8;
    Demoframe(String title)
    {
    super(title);
    p=new Panel();
    p2=new Panel();
    p3=new Panel();
    p4=new Panel();
    p5=new Panel();
    p6=new Panel();
    p7=new Panel();
    p8=new Panel();
    b1=new Button("Home");
    b2=new Button("Courses");
    b3=new Button("Exit");
    b4=new Button("Login");
    cb1=new Button("Majesty");
    cb2=new Button("Excellency");
    cb3=new Button("Merit");
    ad1=new Button("councellor");
     ad2=new Button("accountant");
     ad3=new Button("Manager");
    m2=new Button("Visula effects");
    m3=new Button("Multi media");
     m1=new Button("Animations");
    
    m4=new Button("Server based technology");
    
    p.add(b1);
    p.add(b2);
    p.add(b3);
    p.add(b4);
    
    
    add(p,BorderLayout.NORTH);
    b1.addActionListener(this);
    b3.addActionListener(this);
    b2.addActionListener(this);
    b4.addActionListener(this);
    setSize(400,400);
    setVisible(true);
    }
                   public static void main(String args[])
                       {
                       new Demoframe("Hapl 1.0 v");
                        }
    
    public void actionPerformed(ActionEvent e)
    {
    
    
                     if(e.getSource()==b1)
                          {
    
                           setBackground(Color.white);
    
                            p3.removeAll();
                            p4.removeAll();
                                   }
    
         
    
         if(e.getSource()==b2)
            {
    
              
    
            setBackground(Color.white);
           p4.removeAll();
              p3.add(cb1);
            p3.add(cb2);
            p3.add(cb3);     
      setVisible(true);
              add(p3,BorderLayout.SOUTH);
         cb1.addActionListener(this);
           cb2.addActionListener(this);
            cb3.addActionListener(this);
     if(e.getSource()==cb1)
    {
    p3.add(m1);
    p3.add(m2);
    p3.add(m3);
    p3.add(m4);
    
      setVisible(true);
    setBackground(Color.white);
    m1.addActionListener(this);
           m2.addActionListener(this);
            m3.addActionListener(this);
    
    
     
              add(p3,BorderLayout.SOUTH);
            
    
      }
                                       
    }
    
                                     if(e.getSource()==b3)
                                          {
                                         System.exit(0);
                                           }
                      
    
                       if(e.getSource()==b4)
                         {
                         setBackground(Color.white);
                         p4.add(ad1);
                          p4.add(ad2);
                         p4.add(ad3);
                          p3.removeAll();
                           setVisible(true);
    
                            add(p4,BorderLayout.WEST);
                          ad1.addActionListener(this);
                          ad2.addActionListener(this);
                         ad3.addActionListener(this);
                             
    
    
    
      }
    }
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,423
    Rep Power
    25

    Default

    After you change the contents of a container, you need to tell the container to redo the display of its contents. I think validate() does that.

Similar Threads

  1. Problem with Midlet back button
    By Poonam in forum CLDC and MIDP
    Replies: 5
    Last Post: 11-17-2008, 09:14 AM
  2. java applet button problem .. :( plz help!
    By i4gotmyid in forum Java Applets
    Replies: 1
    Last Post: 04-17-2008, 04:11 PM
  3. java applet button problem .. :( plz help
    By i4gotmyid in forum New To Java
    Replies: 0
    Last Post: 04-05-2008, 09:55 AM
  4. Using SWT Button
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 09:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •