• Post Reply Bookmark Topic Watch Topic
  • New Topic

GUI switching forms  RSS feed

 
rahul sk
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i got a mainMenu jframe form.It was 2 buttons.Button A and buttonB.

When i click on button A,i want to be directed to form A.
When i click on button B,i want to be directed to form B.

How do i go about doing this.


Would be great if some one could help me out.

Rahul
[ May 03, 2008: Message edited by: rahul sk ]
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.


Suggest:
  • Create a private inner class which implements ActionListener, and has a form as a private field.
  • Set up the form in the constructor.
  • set up code to open the appropriate forms in the actionPerformed method.
  • Add an object of this class to each button with its addActionListener method
  •  
    Ilja Preuss
    author
    Sheriff
    Posts: 14112
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    What part do you have doubts about?
     
    pete stein
    Bartender
    Posts: 1561
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Also as was mentioned in your same question in the Sun Java forums, consider using CardLayout here.
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser Redhat VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    "rahul sk",
    Please check your private messages regarding an important administrative matter.
    -Ben
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!