Results 1 to 2 of 2
- 05-30-2011, 08:43 PM #1Member
- Join Date
- Nov 2010
- VT, USA
- Rep Power
Playing cards on other than a JLayeredPane, or not?
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,
- 05-30-2011, 09:37 PM #2Senior Member
- Join Date
- Jul 2009
- Rep Power
- By abc in forum AWT / SwingReplies: 3Last Post: 01-06-2011, 04:40 PM
- By chyrl in forum Advanced JavaReplies: 5Last Post: 08-30-2010, 04:28 AM
- By khunmato in forum New To JavaReplies: 13Last Post: 09-06-2009, 05:47 PM
- By carl in forum Java AppletsReplies: 1Last Post: 08-03-2007, 08:48 PM