Results 1 to 2 of 2
  1. #1
    snieuw is offline Member
    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0

    Default Using a FlowLayout on top of a CardLayout

    Hi everybody,
    I want to use multiple panels as cards in a cardlayout. Therefore I created one Panel with cardLayout and multiple panels with flowlayout, and added those to the first panel.

    The following code is part of my "gui extends JFrame" class:

    Java Code:
        
    JPanel cards = new JPanel(new CardLayout());
    UnitCard unitPanel = new UnitCard(new FlowLayout(FlowLayout.LEFT, 10, 10));
    
    cards.add(unitPanel, "unitPanel");
    this.getContentPane().add(cards);
    this.setLayout(new FlowLayout());
    Everything works fine so far. But I would like to use the flowlayout, so that components are automatically arranged on the underlying panel, e.g. moved to the next line when making the window smaller. If I don't use cardLayout this works just fine. Now it doesn't. Any ideas what might be the reason for this?

    Thanks for your help!
    Greetings
    Steffen

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. Help with CardLayout
    By Kyle227 in forum New To Java
    Replies: 4
    Last Post: 05-28-2010, 01:03 AM
  2. FlowLayout Problem
    By sessomw5098 in forum New To Java
    Replies: 4
    Last Post: 04-21-2010, 01:57 AM
  3. A few question about FlowLayout
    By glhansen in forum New To Java
    Replies: 3
    Last Post: 03-23-2009, 10:19 PM
  4. New Line in FlowLayout
    By chris12295 in forum New To Java
    Replies: 1
    Last Post: 12-07-2007, 05:49 PM
  5. Help Using FlowLayout Manager
    By toad in forum New To Java
    Replies: 2
    Last Post: 12-03-2007, 12:43 AM

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
  •