Results 1 to 3 of 3
  1. #1
    tooktook22 is offline Member
    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    0

    Default adding multiple jpanels to content pane

    hi, is it possible to display another jpanel in the frame instead of opening a new frame each time?


    public void actionPerformed(ActionEvent e)
    {
    JFrame aFrame = new JFrame();
    aFrame.setBounds(0,0,400,600);
    Container contentPane = aFrame.getContentPane();
    JButton s = (JButton)e.getSource();
    if(s == attack)
    {
    contentPane.add(new Attack());
    }
    else if(s == defense)
    {
    contentPane.add(new Defense());
    }
    aFrame.setVisible(true);

    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

Similar Threads

  1. Centering things a content pane
    By RKhadder in forum New To Java
    Replies: 1
    Last Post: 09-28-2010, 01:43 AM
  2. Update the JFrame after change the Content Pane
    By alisonchan30 in forum AWT / Swing
    Replies: 1
    Last Post: 04-26-2010, 06:22 AM
  3. Dynamically adding JPanels to the JTabbedPane !!
    By Stephen Douglas in forum New To Java
    Replies: 1
    Last Post: 04-12-2010, 05:54 PM
  4. Changing content pane of a JFrame?
    By dunafrothint in forum AWT / Swing
    Replies: 1
    Last Post: 03-11-2010, 10:21 PM
  5. Replies: 3
    Last Post: 01-05-2008, 11:13 PM

Tags for this Thread

Posting Permissions

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