Results 1 to 2 of 2
  1. #1
    Markgm is offline Member
    Join Date
    Nov 2010
    Location
    VT, USA
    Posts
    31
    Rep Power
    0

    Default Playing cards on other than a JLayeredPane, or not?

    Hi,
    I am sitting on a bunch of code for playing card games. It is all on a JLayeredPane, with stacks of cards in a board area (rows by columns of stacks of cards). Each card image is in a JLabel. The way I originally did it, the window was resized to just the size for the card game to be played, since each variation uses a slightly different amount of space (for variations in how many rows and columns).

    Go to maximize the window, which some folks like, and the whole thing is a JLayeredPane with all the card stacks on the top left. I could write code to respond to window size changes, and reposition every stack at that time. Right now, this is something that needs to be attended to.

    I also have a "control panel", which has about a dozen swing controls on it, on the pane at right.

    I want to add a game "walk-through", where the above panels are contained inside of another that adds a text box and a few navigation controls for making walk-throughs of the game with accompanying narrative. Can I put a JLayeredPane inside of a JLayeredPane? Is there some other kind of pane I could use for stacks of cards that would work allright? I'm wondering if I should just re-calc the positions of things on window resize events, and do everything on one big JLayeredPane... Walk-through, plain game, in any event.

    It would be convenient if the "board", which has all the stacks of cards, was on its own panel, and where all the stacks could be placed using x,y coords on the panel. Cards have to move and be placed on top, but I don't have to access cards not on top (of their respective stacks). Is there a non-top-level panel that can do that?

    Then, I could have a main window and put that panel at the center of it, with control panel to right, and walk-through stuff on bottom. Also, to use pieces of the overall code, some in a standalone app, some in a partial applet, and place panels various ways. Right now, I'm stuck on an absolute grid for the main window.

    TIA and cheers,
    Mark

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,233
    Rep Power
    6

Similar Threads

  1. JLayeredPane not displaying components
    By abc in forum AWT / Swing
    Replies: 3
    Last Post: 01-06-2011, 03:40 PM
  2. How to add JScrolPane to a JLayeredPane?
    By chyrl in forum Advanced Java
    Replies: 5
    Last Post: 08-30-2010, 04:28 AM
  3. Deck of Cards
    By khunmato in forum New To Java
    Replies: 13
    Last Post: 09-06-2009, 05:47 PM
  4. Help with Random cards
    By carl in forum Java Applets
    Replies: 1
    Last Post: 08-03-2007, 08:48 PM

Posting Permissions

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