1

I am creating a Swing based application , which actually consist of two buttons as shown below -

Main Interface

now what i want is when first button is clicked it must perform a action like showing a panel containing label, textfields , and some buttons in the same frame as shown below -

First button action

and when second button is clicked it will show another panel in the same frame as shown below ..

Second button

the thing is i am not understanding how to make this interface in action by providing event handler and action listener .. So please letme me know how can i archive this . Any help would be appreciated .. Thanks

Markus
  • 1,649
  • 1
  • 22
  • 41
Sukupa91
  • 133
  • 3
  • 9
  • 1
    What ever you are trying is called `tabbed pane` in java swings.. Check here http://docs.oracle.com/javase/tutorial/uiswing/components/tabbedpane.html – AJ. Feb 17 '14 at 08:10
  • @AJ. I am sure its not tabbed pane ... – Sukupa91 Feb 17 '14 at 08:38

1 Answers1

3

There are 2 approaches.

  1. CardLayout based.
    Create all the panels (empty, panel with fields, panel with list) and add them in a container with CardLayout (the empty one is default). On click buttons swap visible cards (panels) showing necessary one.

  2. Recreation based.
    On click button create a new panel with new content. Remove the old one from container and add the newly created pane. After then call:

    container.revalidate();
    container.repaint();
    
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
StanislavL
  • 56,971
  • 9
  • 68
  • 98
  • CardLayout it is .. can you mention any link to explain this kind of functioning tutorial .. i have searched but could not find .. but thanks this is exactly what i want . – Sukupa91 Feb 17 '14 at 08:41